1.添加类库
compile 'fm.jiecao:jiecaovideoplayer:2.0'2.添加布局
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayer android:id="@+id/videocontroller1" android:layout_width="match_parent" android:layout_height="200dp" />3.设置视频/MP3地址、缩略图地址、标题
JCVideoPlayer jCVideoPlayer = (JCVideoPlayer) findViewById(R.id.videocontroller); videoController.setUp("视频/MP3地址","视频/MP3标题"); videoController.ivThumb.setThumbInCustomProject("视频/MP3缩略图地址");4.在包含播放器的Fragment或Activity的onPause()方法中调用JCVideoPlayer.releaseAllVideos();
注:全屏导致崩溃的请在清单文件中当前activity中加上:
[html] view plain copy print ? <activity android:name=“.activity.MainActivity” android:configChanges=“orientation” android:screenOrientation=“portrait”></activity> <activity android:name=".activity.MainActivity" android:configChanges="orientation" android:screenOrientation="portrait"></activity>
</div>