ijkPlayer
https://blog.csdn.net/thw_m/article/details/78851414
依赖
implementation ‘com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5’
布局
<include
layout="@layout/simple_player_view_player"
android:layout_width="match_parent"
android:layout_height="300dp"/>
权限
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
MainActivity
package com.example.day20rk;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.dou361.ijkplayer.widget.PlayStateParams;
import com.dou361.ijkplayer.widget.PlayerView;
public class MainActivity extends AppCompatActivity {
private PlayerView play;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4";
play = new PlayerView(this)
.setTitle("视频播放")
.setScaleType(PlayStateParams.fitparent)
.hideMenu(true)
.forbidTouch(false)
.setPlaySource(url)
.startPlay();
}
@Override
protected void onStop() {
super.onStop();
play.stopPlay();
}
}