添加依赖(SDK:16)
compile 'fm.jiecao:jiecaovideoplayer:5.5'
清单文件
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".Jiaozivideoplayer" android:configChanges="orientation|screenSize|keyboardHidden" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.cll.caolilu1508b20171117.Jiaozivideoplayer"> <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/jiecao_Player" android:layout_width="match_parent" android:layout_height="match_parent"></fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard> </LinearLayout> 主代码package com.example.cll.caolilu1508b20171117; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; public class Jiaozivideoplayer extends AppCompatActivity { private JCVideoPlayerStandard mJiecaoPlayer; 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_jiaozivideoplayer); initView(); getSupportActionBar().setTitle("jiecaovideoplayer的使用"); mJiecaoPlayer.setUp(s1,mJiecaoPlayer.SCREEN_LAYOUT_NORMAL,"葫芦娃"); } @Override public void onBackPressed() { if (JCVideoPlayer.backPress()){ return; } super.onBackPressed(); } @Override protected void onPause() { super.onPause(); JCVideoPlayer.releaseAllVideos(); } private void initView() { mJiecaoPlayer = (JCVideoPlayerStandard) findViewById(R.id.jiecao_Player); } }