ijkplayer是Bilibili基于ffmpeg开发并开源的轻量级视频播放器,支持播放本地网络视频,也支持流媒体播放。支持Android&iOS。
ijkplayer的编译这里不多阐述,我也是直接获取别人编译完成的so库文件,直接使用的。如果你对ijkplayer的编译感兴趣,可以百度一下,有很多文章。
//首页我们要导入依赖包
- compile 'fm.jiecao:jiecaovideoplayer:5.5'
下面就是对应的布局页面 xml
- <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
- android:id="@+id/jiecao_Player"
- android:layout_width="match_parent"
- android:layout_height="200dp"></fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard>
- package myapp.czw.com.ceshi;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
- import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;
- //jiecaovideoplayer视频播放
- //这个播放器本身就具有自动记忆播放进度的功能,全屏状态下具有手势快进和快退的功能,以及左边控制亮度,右边控制音量
- //点击全屏后视频还是竖屏,需要旋转手机才能变成横屏播放
- public class JieCaoVideoActivity extends AppCompatActivity {
- private JCVideoPlayerStandard jcVideoPlayerStandard;
- String s1="http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4";
- String s2="http://player.youku.com/player.php/sid/XMjUyODI2NDc2MA==/v.swf";//不支持swf格式的视频播放
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_jie_cao_video);
- getSupportActionBar().setTitle("jiecaovideoplayer的使用");
- jcVideoPlayerStandard= (JCVideoPlayerStandard) findViewById(R.id.jiecao_Player);
- jcVideoPlayerStandard.setUp(s1,jcVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,"视频标题");
- }
- @Override
- public void onBackPressed() {
- if (JCVideoPlayer.backPress()){
- return;
- }
- super.onBackPressed();
- }
- @Override
- protected void onPause() {
- super.onPause();
- JCVideoPlayer.releaseAllVideos();
- }
- }
清单文件中也需要加一些东西
- <activity android:name=".JieCaoVideoActivity"
- android:configChanges="orientation|screenSize|keyboardHidden"
- android:screenOrientation="portrait"></activity>