|
|
@@ -66,6 +66,13 @@ public class SwiftDubbingLibPlugin: NSObject, FlutterPlugin {
|
|
|
let outPath = pathVideoMixinDir + "\(videoId)_mix.mp4";
|
|
|
startMixinAudio(videoPath: videoPath, bgmPath: bgmPath, audioPathList: audioPathList, startTimeList: startTimeList, outPath: outPath, result: result)
|
|
|
break
|
|
|
+ case "startMixinPaintedAudio":
|
|
|
+ let bgmPath = args!["bgmPath"] as! String;
|
|
|
+ let audioPathList = args!["audioPaths"] as! [String];
|
|
|
+ let startTimeList = args!["durationList"] as! [Double];
|
|
|
+ let pathVideoMixinDir = args!["encodePath"] as! String;
|
|
|
+ startMixinAudio(videoPath: nil, bgmPath: bgmPath, audioPathList: audioPathList, startTimeList: startTimeList, outPath: pathVideoMixinDir, result: result)
|
|
|
+ break;
|
|
|
case "getIsMediaPlayPause":
|
|
|
result(audioPlayer != nil && audioPlayer!.isPlaying)
|
|
|
break
|
|
|
@@ -99,10 +106,10 @@ public class SwiftDubbingLibPlugin: NSObject, FlutterPlugin {
|
|
|
}
|
|
|
|
|
|
/// 合成
|
|
|
- func startMixinAudio(videoPath: String, bgmPath: String, audioPathList: [String], startTimeList: [Double], outPath: String, result: @escaping FlutterResult) {
|
|
|
- let videoUrl = URL(fileURLWithPath: videoPath)
|
|
|
+ func startMixinAudio(videoPath: String?, bgmPath: String, audioPathList: [String], startTimeList: [Double], outPath: String, result: @escaping FlutterResult) {
|
|
|
+ let videoUrl:URL? = videoPath.isBlank ?URL(fileURLWithPath: videoPath!):nil
|
|
|
let musicUrl = URL(fileURLWithPath: bgmPath)
|
|
|
- let composer = DubbingComposer(timeline: startTimeList, videoUrl: videoUrl, musicUrl: musicUrl, recordsUrl: audioPathList)
|
|
|
+ let composer = DubbingComposer(timeline: startTimeList, videoUrl: videoUrl!, musicUrl: musicUrl, recordsUrl: audioPathList)
|
|
|
composer.preTime = preLag
|
|
|
let outputUrl = URL(fileURLWithPath: outPath)
|
|
|
DispatchQueue.global().async {
|
|
|
@@ -220,3 +227,18 @@ extension SwiftDubbingLibPlugin: AVAudioPlayerDelegate {
|
|
|
// self.result!(false)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+extension String{
|
|
|
+
|
|
|
+ /// check string cellection is whiteSpace
|
|
|
+ var isBlank : Bool{
|
|
|
+ return allSatisfy({$0.isWhitespace})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+extension Optional where Wrapped == String{
|
|
|
+ var isBlank : Bool{
|
|
|
+ return self?.isBlank ?? true
|
|
|
+ }
|
|
|
+}
|