簡單制作短視頻Demo
阿新 • • 發佈:2018-12-25
con options onerror tint player stl prepare nvi roi
準備材料並配置項目工程:
1、去下載七牛雲播放器SDK
2、然後把pldroid-player-2.1.6.jar包拷貝到你項目lib文件裏,詳情如下圖所示: implementation ‘com.android.support:appcompat-v7:27.1.0‘
implementation ‘com.journeyapps:zxing-android-embedded:3.0.2@aar‘
implementation ‘com.google.zxing:core:3.2.0‘
}
準備材料並配置項目工程:
1、去下載七牛雲播放器SDK
2、然後把pldroid-player-2.1.6.jar包拷貝到你項目lib文件裏,詳情如下圖所示:
3、把整個jniLibs文件夾裏面的所有內容都拷貝到你項目src/main/裏,詳情如下圖所示:
4、然後在你項目build.gradle進行關聯
android {
sourceSets {
main {
jniLibs.srcDirs = [‘src/main/jniLibs‘]
}
}
}
dependencies {
implementation files(‘libs/pldroid-player-2.1.6.jar‘)
implementation ‘com.bugsnag:bugsnag-android-ndk:1.1.2‘
implementation ‘com.journeyapps:zxing-android-embedded:3.0.2@aar‘
implementation ‘com.google.zxing:core:3.2.0‘
}
5、然後在你項目xml布局裏添加如下代碼,PLVideoView控件:
<com.pili.pldroid.player.widget.PLVideoView android:id="@+id/VideoView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" />
6、最後去在你Activity裏找到這個控件並配置播放器代碼:
mVideoView = findViewById(R.id.VideoView); AVOptions options = new AVOptions(); options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000); options.setInteger(AVOptions.KEY_MEDIACODEC, AVOptions.MEDIA_CODEC_SW_DECODE); options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1 ); options.setInteger(AVOptions.KEY_LOG_LEVEL, 0); mVideoView.setAVOptions(options); // Set some listeners mVideoView.setOnInfoListener(mOnInfoListener); mVideoView.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener); mVideoView.setOnBufferingUpdateListener(mOnBufferingUpdateListener); mVideoView.setOnCompletionListener(mOnCompletionListener); mVideoView.setOnErrorListener(mOnErrorListener); mVideoView.setOnVideoFrameListener(mOnVideoFrameListener); mVideoView.setOnAudioFrameListener(mOnAudioFrameListener); mVideoView.setVideoPath(videoPath); mVideoView.setDisplayAspectRatio(mDisplayAspectRatio); mVideoView.setLooping(true); // You can also use a custom `MediaController` widget mMediaController = new MediaController(this, !mIsLiveStreaming, mIsLiveStreaming); mMediaController.setOnClickSpeedAdjustListener(mOnClickSpeedAdjustListener); mVideoView.setMediaController(mMediaController); 最後展示一下效果:
最後附上本人github,代碼下載地址:https://github.com/Visen123/MyShortVideo ,如果覺得使用方便,請給我的github 點個贊,謝謝
簡單制作短視頻Demo