控件与三方的依赖

节操播放器Jiecaovideoplayer简单使用方法

2018-12-28  本文已影响1288人  DN_妖小孽

1.buildgride中添加如下代码

implementation 'fm.jiecao:jiecaovideoplayer:5.5'

2.布局文件中添加

<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
        android:id="@+id/jiecao_Player"
        android:layout_width="match_parent"
        android:layout_height="293dp"></fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard>

3.创建activity

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;


/**
 * Created by mayiyahei on 2018/12/15.
 */

public class ZiliaoVideoActivity extends AppCompatActivity{
    private JCVideoPlayerStandard jcVideoPlayerStandard;
    String s3 = "http://v.yongjiujiexi.com/20180304/B0cYHQvY/index.m3u8";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    }

    private void getdata() {
            jcVideoPlayerStandard.setUp(s3,jcVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,"视频标题");
    }

    @Override
    public void onResume() { 
        // TODO Auto-generated method stub
        getdata();
        super.onResume();
    }

    @Override
    public void onBackPressed() { "全屏竖屏切换的时候继续播放"
        if (JCVideoPlayerStandard.backPress()){
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayerStandard.releaseAllVideos();
    }

    @Override
    public void onDestroy() { "activity销毁的时候释放资源,播放器停止播放"
        super.onDestroy();
        try {
            jcVideoPlayerStandard.releaseAllVideos();
        } catch (Exception e) {
        }
    }
}

4.注意

manifests文件中此activity要添加屏幕转换权限

<activity android:name=".Activitys.Video.ZiliaoVideoActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"/>
        <!-- android:theme="@style/AppTheme.NoActionBar"/ -->
上一篇下一篇

猜你喜欢

热点阅读