阿里云短视频Android-SDK编辑视频音乐

  • 编辑的核心接口在VlogEditManager.java中。

视频预览

  • 完成拍摄或选取本地视频,对已完成拍摄的视频或本地视频根据需要进行编辑,参数数据聚合到VlogEditManager里进行渲染预览。
  • 代码示例如下:

//初始化预览视图 private boolean initMultiMediaVideoView() { mVideoView.setZOrderMediaOverlay(true); if (ListUtils.isEmpty(mDataSourceList)) { return false; } mDataEditManager = new UgcPreviewEditDataManager(); mMultiMediaDataSourceViewAdapter = new MultiMediaDataSourceViewAdapter(); mVlogEditManager = new VlogEditManager(mMultiMediaDataSourceViewAdapter); mVlogEditManager.setMultiMediaTimelineUpdateListener(new MultiMediaTimelineUpdateListener() { @Override public void onTimelineUpdate(long currentPlayTime, long totalDuration) { if (mUgcSubtitleEditController != null && mUgcSubtitleEditController.isShowing()) {mUgcSubtitleEditController.onTimelineUpdate(currentPlayTime, totalDuration); } } }, true); mVideoView.setMultiMediaDataSourceViewAdapter(mMultiMediaDataSourceViewAdapter); mVideoView.setCanMeasure(false); mVlogEditManager.setMultiMediaData(mDataSourceList); // 应用主题效果(特效、滤镜、转场、模板) if (mMediaTrackConfig != null) { mVlogEditManager.setMediaTrackConfig(mMediaTrackConfig); } }
音乐剪辑

  • 音乐裁剪Dialog控件的使用

mHotMusicDialog = new HotMusicDialog(this); mHotMusicDialog.setHotMusicListener(new HotMusicDialog.OnHotMusicListener() {@Overridepublic void selectedMusic(MusicData musicData) {handleMusicResult(musicData);}@Overridepublic void onBgVolume(float progress) {mMusicBgVolume = progress;if (mPreviewMusicPlayer != null) {mPreviewMusicPlayer.setVolume(mMusicBgVolume);}}@Overridepublic void onVolume(float progress) {mOriginMusicVolume = progress;if (mVlogEditManager != null) {mVlogEditManager.setVolume(mOriginMusicVolume);}}@Overridepublic void onSlide(int duration) {if (mPreviewMusicPlayer != null) {if (mPreviewMusicPlayer.mMusicData != null) { mPreviewMusicPlayer.mMusicData.startPosition = duration;}mPreviewMusicPlayer.seek(duration);mPreviewMusicPlayer.onResume();updateMusicDraftBean(mPreviewMusicPlayer.mMusicData);}}@Overridepublic PreviewMusicPlayer getPreviewMusicPlayer() {return mPreviewMusicPlayer;} });