-
Notifications
You must be signed in to change notification settings - Fork 53
audio_range
zanxiaofei edited this page Jun 30, 2017
·
5 revisions
金山云短视频SDK提供背景音乐裁剪功能,可从任意时间裁剪任意时长的音频片段合成到视频中
.Demo中示例了固定时长的背景音乐裁剪:
- 当背景音乐时长大于视频时长时,选择裁剪的起始位置,按照视频时长裁剪音频
- 当背景音乐比视频时长短时,不进行裁剪
- AudioSeekLayout 为BGM裁剪UI示例,欢迎参考
-
KSYEditKit.setBGMRanges(long startTime, long endTime)
: startTime为开始时间,endTime是结束时间 -
KSYEditKit.seekBGM(long position)
: seek背景音乐播放位置
//bgm裁剪ui回调
mAudioSeekListener = new AudioSeekLayout.OnAudioSeekChecked() {
@Override
public void onActionUp(long start, long end) {
//向SDK设置裁剪范围
mEditKit.setBGMRanges(start, end);
}
};
mAudioSeekLayout.setOnAudioSeekCheckedListener(mAudioSeekListener);
// 设置背景音乐播放Prepared的回调
mEditKit.getAudioPlayerCapture().setOnPreparedListener(new IMediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(IMediaPlayer iMediaPlayer) {
mAudioLength = iMediaPlayer.getDuration();
if (mAudioSeekLayout.getVisibility() != View.VISIBLE) {
mAudioSeekLayout.setVisibility(View.VISIBLE);
}
if (mFirstPlay) {
mFirstPlay = false;
//mEditPreviewDuration 预览视频的总时长
mAudioSeekLayout.updateAudioSeekUI(mAudioLength, mEditPreviewDuration);
}
}
});