首先加入依赖
compile 'fm.jiecao:jiecaovideoplayer:5.5'
其次清单文件配置
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<activity android:name=".JieCaoVideoActivity" android:configChanges="orientation|screenSize|keyboardHidden" android:screenOrientation="portrait"> </activity>这.JieCaoVideoActivity报红没事,不用管
主方法
public class MainActivity extends AppCompatActivity { private JCVideoPlayerStandard jcVideoPlayerStandard; private JCVideoPlayerStandard jcVideoPlayerStandard1; String s1="http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4"; String s2="http://player.youku.com/player.php/sid/XMjUyODI2NDc2MA==/v.swf";//不支持swf格式的视频播放 String s3="http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().setTitle("BoBrother"); jcVideoPlayerStandard= (JCVideoPlayerStandard) findViewById(R.id.jiecao_Player); jcVideoPlayerStandard1 = findViewById(R.id.jiecao_Player1); jcVideoPlayerStandard.setUp(s1,jcVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,"牛逼"); jcVideoPlayerStandard1.setUp(s3,jcVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,"好用"); } @Override public void onBackPressed() { if (JCVideoPlayer.backPress()){ return; } super.onBackPressed(); } @Override protected void onPause() { super.onPause(); JCVideoPlayer.releaseAllVideos(); } }布局
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/jiecao_Player" android:layout_width="match_parent" android:layout_height="200dp"> </fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="50" /> <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/jiecao_Player1" android:layout_width="match_parent" android:layout_height="200dp"> </fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard>