第三方开源库之 JieCaoVideoPlayer

由于项目需求,需做一个视频播放器,一方面是监控,一方面是回看录像。本来想用 VideoView 来做,但是在网上发现了这个 JieCaoVideoPlayer 下面先看效果图:

效果图

第三方开源库之 JieCaoVideoPlayer_第1张图片第三方开源库之 JieCaoVideoPlayer_第2张图片第三方开源库之 JieCaoVideoPlayer_第3张图片
第三方开源库之 JieCaoVideoPlayer_第4张图片

使用

1、在 app 文件夹下 build.gradle 文件中添加:

compile 'fm.jiecao:jiecaovideoplayer:5.8.1'

2、在清单文件中添加:


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gyq.videoplayertest">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            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>
    application>

manifest>

3、布局文件


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.gyq.videoplayertest.MainActivity">

    <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
        android:id="@+id/video_player_stand"
        android:layout_width="match_parent"
        android:layout_height="200dp"/>
RelativeLayout>

4、逻辑代码

package com.gyq.videoplayertest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        JCVideoPlayerStandard videoPlayer = (JCVideoPlayerStandard)findViewById(R.id.video_player_stand);

        videoPlayer.setUp("http://www.jmzsjy.com/UploadFile/微课/地方风味小吃——宫廷香酥牛肉饼.mp4", JCVideoPlayer.SCREEN_LAYOUT_NORMAL,"宫廷香酥牛肉饼");

        videoPlayer.thumbImageView.setImageResource(R.drawable.niunou);     //播放前显示的图片
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }
}

真好用!!!

你可能感兴趣的:(第三方开源库)