为帮助用户更好更快的使用插件,论坛维护了一个示例,示例中包含示例代码、知识点讲解、注意事项等,供您参考。
短视频 录制 滤镜 美颜 贴纸 合成 剪切 编辑 音乐合成
插件概述
短视频 录制 滤镜 美颜 贴纸 合成 剪切 编辑 音乐合成 ios:GPUImage android:ffmpeg
插件初始化
var musicList= [{
"name": "双节棍",
"cover": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597210302718&di=c64eacfd47ddc43b83b3b090541c6461&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3D3c7c62e4d339b6004dce0fbfd9513526%2F45f8f8061d950a7b2bba2fc30cd162d9f3d3c91e.jpg",
"author": "周杰伦",
"duration": "3:20",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic1.mp3"
}, {
"name": "忘清水",
"cover": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597210453818&di=96fd89c95b9b087e3536ea94cc768613&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn07%2F341%2Fw980h961%2F20180510%2F25b5-haichqz3526243.jpg",
"author": "刘德华",
"duration": "3:30",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic2.mp3"
}, {
"name": "斗破苍穹",
"cover": "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1868303863,3901783072&fm=26&gp=0.jpg",
"author": "刘亦菲",
"duration": "3:40",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic3.mp3"
}];
//贴纸 初始化传入 未完善 暂时不要用
var resource =[{
name:'test_sticker1',//静态贴纸 人脸识别可以关闭
zipPath:'assets://widget/resource/test_sticker1.zip',
thumbPath:'assets://widget/resource/test_sticker1.png'
}];
ox.init({
resource:[],//贴图道具 未完善 暂时不要用
musicList:musicList //音乐列表
},function(ret) {
var code= ret.code;
//0 成功
}
});
录制监听接口
ox.addEventListener(function(ret) {
var code= ret.code;
//-1 错误信息
//0 关闭按钮事件
//1 录制完成返回 path cover
//2 音乐搜索按钮事件
//3 上传按钮事件
}
});
Android,ios系统
可提供的1.0.0
设置全局音乐列表 可用于下拉刷新
var musicList = {list: [{
"name": "双节棍",
"cover": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597210302718&di=c64eacfd47ddc43b83b3b090541c6461&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3D3c7c62e4d339b6004dce0fbfd9513526%2F45f8f8061d950a7b2bba2fc30cd162d9f3d3c91e.jpg",
"author": "周杰伦",
"duration": "3:20",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic1.mp3"
}, {
"name": "忘清水",
"cover": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597210453818&di=96fd89c95b9b087e3536ea94cc768613&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn07%2F341%2Fw980h961%2F20180510%2F25b5-haichqz3526243.jpg",
"author": "刘德华",
"duration": "3:30",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic2.mp3"
}, {
"name": "斗破苍穹",
"cover": "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1868303863,3901783072&fm=26&gp=0.jpg",
"author": "刘亦菲",
"duration": "3:40",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic3.mp3"
}]};
var ox = api.require('oxRecorder');
ox.setMusics(musicList);
Android,ios系统
可提供的1.0.0
打开录制
var ox = api.require('oxRecorder');
ox.openRecord({
rect: {
x: 0,
y: 0,
w: w,
h: h
},
fixedOn: api.frameName,
fixed: true,
front: true, //默认开启摄像头 前置
});
Android,ios系统
可提供的1.0.0
暂停录制
var ox = api.require('oxRecorder');
ox.pauseRecord();
Android,ios系统
可提供的1.0.0
恢复录制
var ox = api.require('oxRecorder');
ox.resumeRecord();
Android,ios系统
可提供的1.0.0
设置录制背景音乐
var ox = api.require('oxRecorder');
ox.setRecordMusic({musicPath:'',musicName:''});
Android,ios系统
可提供的1.0.0
打开音乐选择器
var ox = api.require('oxRecorder');
ox.openMusicPicker({
openType: 0 //openType 0 录制 弹出音乐 1 编辑弹出音乐
}, function(ret) {
var code = ret.code;
if (code == 0) {
//关闭事件
api.alert({msg: JSON.stringify(ret)})
} else if (code == 1) {
//音乐选择返回
api.alert({msg: JSON.stringify(ret)})
} else if (code == 2) {
//下拉刷新返回 跟新音乐数据
var list = {
list: [{
"name": "11111",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic1.mp3"
}, {
"name": "22222",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic2.mp3"
}, {
"name": "33333",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic3.mp3"
}, {
"name": "44444444",
"url": "http://dldir1.qq.com/hudongzhibo/LiteAV/demomusic/testmusic3.mp3"
}]
};
ox.setMusics(list);
}
});
Android,ios系统
可提供的1.0.0
音乐列表弹出界面关闭
var ox = api.require('oxRecorder');
ox.closeMusicPicker()
Android,ios系统
可提供的1.0.0
打开视频选择器 进行视频合成
var ox = api.require('oxRecorder');
ox.openVideoPicker(function(ret) {
var code = ret.code;
if (code == 0) {
//合成视频路径返回 path cover
api.alert({msg: JSON.stringify(ret)})
}
});
Android,ios系统
可提供的1.0.0
关闭视频选择器
var ox = api.require('oxRecorder');
ox.closeVideoPicker();
Android,ios系统
可提供的1.0.0
打开视频剪切
var ox = api.require('oxRecorder');
ox.openVideoCut({path:''}, function(ret) {
//code 0返回事件 1 返回剪切视频地址 -1 视频地址不存在
var code = ret.code;
ox.closeVideoCut();
});
Android,ios系统
可提供的1.0.0
关闭视频剪切
var ox = api.require('oxRecorder');
ox.closeVideoCut();
Android,ios系统
可提供的1.0.0
打开视频编辑
var ox = api.require('oxRecorder');
ox.openVideoEdit({path:''}, function(ret) {
//code 0返回事件 1 返回剪切视频地址 封面 path cover -1 视频地址不存在
var code = ret.code;
});
Android,ios系统
可提供的1.0.0
关闭视频编辑
var ox = api.require('oxRecorder');
ox.closeVideoEdit();
Android,ios系统
可提供的1.0.0