1,添加依赖

compile 'cn.jzvd:jiaozivideoplayer:6.2.12'// glide 4.7compile 'com.github.bumptech.glide:glide:4.7.1'annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

添加权限:

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

2,布局文件中引入:

<cn.jzvd.JZVideoPlayerStandard        android:id="@+id/videoplayer"        android:layout_width="match_parent"        android:layout_height="200dp"/>

3,设置视频地址、缩略图地址、标题

JZVideoPlayerStandard jzvdStd = (JZVideoPlayerStandard) findViewById(R.id.videoplayer);        // 设置这两句切换时会直接进入横屏全屏模式        JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;  //横向        JZVideoPlayer.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;  //纵向//        设置播放器播放地址,标题        jzvdStd.setUp("http://jzvd.nathen.cn/342a5f7ef6124a4a8faf00e738b8bee4/cf6d9db0bd4d41f59d09ea0a81e918fd-5287d2089db37e62345123a1be272f8b.mp4"                ,JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, "好孩子" );        //设置播放器封面        Glide.with(this)                .load("http://jzvd-pic.nathen.cn/jzvd-pic/1bb2ebbe-140d-4e2e-abd2-9e7e564f71ac.png")                .into(jzvdStd.thumbImageView);

4,在Activity中:

@Override    public void onBackPressed() {        if (JZVideoPlayerStandard.backPress()) {            return;        }        super.onBackPressed();    }    @Override    protected void onPause() {        super.onPause();        JZVideoPlayerStandard.releaseAllVideos();    }

5,在AndroidManifest.xml中:

<activity    android:name=".MainActivity"    android:configChanges="orientation|screenSize|keyboardHidden"    android:screenOrientation="portrait" />

更多相关文章

  1. android 模拟器访问本机http服务IP地址问题
  2. Android(安卓)webview解析 ,webview点击获取图片地址
  3. RecycleView 单选 以及多选单选互斥两种状态 和多选
  4. 【Android】Android开源项目分类汇总
  5. Cocos2d-x12和NDK-r8编译android
  6. Android(安卓)程式开发:(一)详解Activity —— 1.3隐藏标题栏
  7. GitHub 上一些优秀的 Android(安卓)开源项目
  8. Android(安卓)图文数据JSON解析,金山词霸每日一句API的调用
  9. android window.requestWindowFeature()常用方法(转)

随机推荐

  1. Android ORM 框架:GreenDao 使用详解(基础
  2. Android随VierPager滑动的导航栏
  3. Android(安卓)记事本-Demo
  4. android:ems 属性
  5. android 吸顶效果+下拉刷新 CoordinatorL
  6. Android自动测试框架Espresso
  7. 【Android 开发】:Android中EditText控件
  8. Android自学笔记之 Activity详解
  9. Android(安卓)drawText获取text宽度的三
  10. gradle for android 自动找当前环境当前