? ? 下面制作完后短視頻效果圖,如下:
看完效果圖,是不是覺(jué)得很簡(jiǎn)單引有,現(xiàn)在開(kāi)始講一下,如何制作短視頻倦逐,具體做法如下介紹:
準(zhǔn)備材料并配置項(xiàng)目工程:
1譬正、去下載七牛云播放器SDK
2、然后把pldroid-player-2.1.6.jar包拷貝到你項(xiàng)目lib文件里檬姥,詳情如下圖所示:
3曾我、把整個(gè)jniLibs文件夾里面的所有內(nèi)容都拷貝到你項(xiàng)目src/main/里,詳情如下圖所示:
4健民、然后在你項(xiàng)目build.gradle進(jìn)行關(guān)聯(lián)
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.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'
}
5抒巢、然后在你項(xiàng)目xml布局里添加如下代碼,PLVideoView控件:
6秉犹、最后去在你Activity里找到這個(gè)控件并配置播放器代碼:
mVideoView = findViewById(R.id.VideoView);AVOptionsoptions = newAVOptions();? ? 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 listenersmVideoView.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` widgetmMediaController = new MediaController(this, !mIsLiveStreaming, mIsLiveStreaming);? ? mMediaController.setOnClickSpeedAdjustListener(mOnClickSpeedAdjustListener);? ? mVideoView.setMediaController(mMediaController);? ? ? ? ? ? 最后展示一下效果:
最后附上代碼下載地址:https://github.com/Visen123/ShortVideo蛉谜,如果覺(jué)得使用方便稚晚,請(qǐng)給我的github 點(diǎn)個(gè)贊,謝謝型诚!