首先导入依赖
compile 'com.github.open-android:IjkPlayer:1.0.0'
implementation 'com.facebook.fresco:fresco:0.13.0'
implementation 'com.facebook.fresco:animated-gif:0.13.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
以及网路权限
一个简单的视图
//Mainactivity
public class MainActivity extends AppCompatActivity {
private IjkPlayerView mPlayerView;
private SimpleDraweeView sdv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
mPlayerView = (IjkPlayerView) findViewById(R.id.player_view);
sdv = (SimpleDraweeView) findViewById(R.id.sdv);
Uri mUri = Uri.parse("http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4");
mPlayerView.init()
.setVideoPath(mUri)
.setMediaQuality(IjkPlayerView.MEDIA_QUALITY_SMOOTH)
.enableDanmaku()
.start();
initView();
sdv.setImageURI("http://pic.58pic.com/58pic/13/17/54/40J58PICyAY_1024.jpg");
}
@Override
protected void onResume() {
super.onResume();
mPlayerView.onResume();
}
@Override
protected void onPause() {
super.onPause();
mPlayerView.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
mPlayerView.onDestroy();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mPlayerView.configurationChanged(newConfig);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (mPlayerView.handleVolumeKey(keyCode)) {
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onBackPressed() {
if (mPlayerView.onBackPressed()) {
return;
}
super.onBackPressed();
}
private void initView() {
}
}
Ok把这些贴完就能玩成bw项目二最后一天的日考了!