视频播放器

需要添加的依赖

compile 'com.github.leifzhang:IjkLib:0.4.3'

添加的权限

 <uses-permission android:name="android.permission.INTERNET"></uses-permission>

activity_main

  <tv.danmaku.ijk.media.widget.media.IjkVideoView
        android:id="@+id/ijkPlayer"
        android:layout_width="match_parent"
        android:layout_height="200
package com.bawie.www.ijkplayer;

import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import tv.danmaku.ijk.media.widget.media.AndroidMediaController;
import tv.danmaku.ijk.media.widget.media.IjkVideoView;

public class MainActivity extends AppCompatActivity {
    IjkVideoView ijkMediaPlayer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        IjkMediaPlayer.loadLibrariesOnce(null);
        IjkMediaPlayer.native_profileBegin("libijkplayer.so");
        ijkMediaPlayer = (IjkVideoView) findViewById(R.id.ijkPlayer);
        AndroidMediaController controller = new AndroidMediaController(this, false);
        ijkMediaPlayer.setMediaController(controller);
        // adapter = new IdAdapter(SecondActivity.this,list);
        String url = "https://wdl.wallstreetcn.com/41aae4d2-390a-48ff-9230-ee865552e72d";
        // String url = "http://o6wf52jln.bkt.clouddn.com/

        ijkMediaPlayer.setVideoURI(Uri.parse(url));
        ijkMediaPlayer.start();


    }
}

 


posted on 2017-12-21 09:45  权威的程序  阅读(312)  评论(0编辑  收藏  举报