本文主要是介绍IjkVideoView 加 AndroidMediaController 视频播放,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
依赖:
compile 'com.github.leifzhang:IjkLib:0.4.4'
布局:
<tv.danmaku.ijk.media.widget.media.IjkVideoViewandroid:id="@+id/ijvideo"android:layout_width="match_parent"android:layout_height="match_parent"></tv.danmaku.ijk.media.widget.media.IjkVideoView>
主要代码:
public class Main2Activity extends AppCompatActivity {private VideoView vv_video1;private String s="http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4";private IjkVideoView mIjvideo;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main2);mIjvideo = findViewById(R.id.ijvideo);IjkMediaPlayer.loadLibrariesOnce(null);IjkMediaPlayer.native_profileBegin("libijkplayer.so");AndroidMediaController controller = new AndroidMediaController(this, false);mIjvideo.setMediaController(controller); // 链接String url = "http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4";mIjvideo.setVideoURI(Uri.parse(url));mIjvideo.start();}//在生命周期中设置 暂停@Overrideprotected void onPause() {super.onPause();mIjvideo.pause();}@Overrideprotected void onDestroy() {super.onDestroy();IjkMediaPlayer.native_profileEnd();}@Overrideprotected void onResume() {super.onResume();mIjvideo.resume();} }
这篇关于IjkVideoView 加 AndroidMediaController 视频播放的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!