先添加依赖: compile 'com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.5'
MainActivity里面:
1 public class MainActivity extends AppCompatActivity {
2
3 @Override
4 protected void onCreate(Bundle savedInstanceState) {
5 super.onCreate(savedInstanceState);
6 setContentView(R.layout.activity_main);
7 String url = "http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4";
8 //注释的代码可以实现全屏播放
9 // View rootView = getLayoutInflater().from(this).inflate(R.layout.simple_player_view_player, null);
10 // setContentView(rootView);
11 new PlayerView(this)
12 .setTitle("标题")
13 .setScaleType(PlayStateParams.fitparent)
14 .hideMenu(true)
15 .forbidTouch(false)
16 .setPlaySource(url)
17 .startPlay();
18 }
19 }
布局文件:
小屏幕布局文件
1 <include 2 layout="@layout/simple_player_view_player" 3 android:layout_width="match_parent" 4 android:layout_height="180dp"/>
权限:
1 <uses-permission android:name="android.permission.INTERNET"/>
2 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
3 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
4 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>