|
|
@ -36,7 +36,6 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
var downloadDelegate: DownloadDelegate? |
|
|
var downloadDelegate: DownloadDelegate? |
|
|
|
|
|
|
|
|
var loopStart = 0.0 |
|
|
var loopStart = 0.0 |
|
|
var loopEnd = 0.0 |
|
|
|
|
|
|
|
|
|
|
|
var completionHandler: (() -> Void)? |
|
|
var completionHandler: (() -> Void)? |
|
|
|
|
|
|
|
|
@ -56,11 +55,11 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
|
|
|
|
|
|
var aspect = 1 |
|
|
var aspect = 1 |
|
|
|
|
|
|
|
|
var loopOption = 0 |
|
|
|
|
|
|
|
|
var loopMode = false |
|
|
|
|
|
|
|
|
var thumbnailTime: TimeInterval = 0.0 |
|
|
var thumbnailTime: TimeInterval = 0.0 |
|
|
|
|
|
|
|
|
var edit = true |
|
|
|
|
|
|
|
|
var edit = false |
|
|
var allowEdit = true |
|
|
var allowEdit = true |
|
|
var index = 0 |
|
|
var index = 0 |
|
|
|
|
|
|
|
|
@ -74,7 +73,7 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
barbutton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(VideoController.captureThumbnail)); |
|
|
barbutton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(VideoController.captureThumbnail)); |
|
|
navigationItem.rightBarButtonItems = [barbutton!] |
|
|
navigationItem.rightBarButtonItems = [barbutton!] |
|
|
|
|
|
|
|
|
backButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(VideoController.back(_:))) |
|
|
|
|
|
|
|
|
backButton = UIBarButtonItem(title: "0:00", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.back(_:))) |
|
|
speedButton = UIBarButtonItem(title:"1.0", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.speed(_:))) |
|
|
speedButton = UIBarButtonItem(title:"1.0", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.speed(_:))) |
|
|
loopButton = UIBarButtonItem(title:"1.0", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.loop(_:))) |
|
|
loopButton = UIBarButtonItem(title:"1.0", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.loop(_:))) |
|
|
aspectButton = UIBarButtonItem(title:"1", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.aspect(_:))) |
|
|
aspectButton = UIBarButtonItem(title:"1", style:UIBarButtonItem.Style.plain, target: self, action: #selector(VideoController.aspect(_:))) |
|
|
@ -86,11 +85,11 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
|
|
|
|
|
|
view.addSubview(player) |
|
|
view.addSubview(player) |
|
|
player.snp.makeConstraints { (make) in |
|
|
player.snp.makeConstraints { (make) in |
|
|
// make.top.equalTo(self.view).offset(100) |
|
|
|
|
|
|
|
|
// make.top.equalTo(self.view).offset(100) |
|
|
make.left.right.equalTo(self.view) |
|
|
make.left.right.equalTo(self.view) |
|
|
make.height.equalTo(self.view) |
|
|
make.height.equalTo(self.view) |
|
|
// Note here, the aspect ratio 16:9 priority is lower than 1000 on the line, because the 4S iPhone aspect ratio is not 16:9 |
|
|
// Note here, the aspect ratio 16:9 priority is lower than 1000 on the line, because the 4S iPhone aspect ratio is not 16:9 |
|
|
// make.height.equalTo(player.snp.width).multipliedBy(9.0/16.0).priority(750) |
|
|
|
|
|
|
|
|
// make.height.equalTo(player.snp.width).multipliedBy(9.0/16.0).priority(750) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
player.delegate = self |
|
|
player.delegate = self |
|
|
@ -102,20 +101,41 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
if let c = currentItem, let url = c.playerURL { |
|
|
if let c = currentItem, let url = c.playerURL { |
|
|
print(url) |
|
|
print(url) |
|
|
play(url as URL) |
|
|
play(url as URL) |
|
|
// player.playerLayer!.player!.volume = 0.0 |
|
|
|
|
|
|
|
|
// player.playerLayer!.player!.volume = 0.0 |
|
|
|
|
|
|
|
|
update() |
|
|
update() |
|
|
} |
|
|
} |
|
|
|
|
|
loopMode = detailDelegate!.settings().autoloop |
|
|
updateLoop() |
|
|
updateLoop() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func editItem() { |
|
|
func editItem() { |
|
|
let kv = EditItemView(item: currentSnapshot!) |
|
|
|
|
|
|
|
|
let currentItem = player.playerLayer?.player?.currentItem |
|
|
|
|
|
let totalTime : Double |
|
|
|
|
|
|
|
|
|
|
|
if let playerItem = currentItem { |
|
|
|
|
|
totalTime = TimeInterval(playerItem.duration.value) / TimeInterval(playerItem.duration.timescale) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
totalTime = 1000 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let kv = EditItemView(item: currentSnapshot!, len: totalTime, seek: |
|
|
|
|
|
{ value in |
|
|
|
|
|
print(value) |
|
|
|
|
|
self.player.seekSmoothlyToTime(newChaseTime: value) |
|
|
|
|
|
}, capture: { item in |
|
|
|
|
|
item.scale = Double(self.player.zoom) |
|
|
|
|
|
item.offset = CGPoint(x: self.player.xpos, y: self.player.ypos) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
let pc = UIHostingController(rootView: kv) |
|
|
let pc = UIHostingController(rootView: kv) |
|
|
|
|
|
pc.view.backgroundColor = .clear |
|
|
let navController = UINavigationController(rootViewController: pc) // Creating a navigation controller with pc at the root of the navigation stack. |
|
|
let navController = UINavigationController(rootViewController: pc) // Creating a navigation controller with pc at the root of the navigation stack. |
|
|
// navController.modalPresentationStyle = .fullScreen |
|
|
|
|
|
|
|
|
// navController.modalPresentationStyle = .popover |
|
|
|
|
|
|
|
|
present(navController, animated: false, completion: nil) |
|
|
present(navController, animated: false, completion: nil) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -146,6 +166,8 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
edit = true |
|
|
edit = true |
|
|
|
|
|
loopMode = false |
|
|
|
|
|
updateLoop() |
|
|
reviewButton!.tintColor = UIColor.yellow |
|
|
reviewButton!.tintColor = UIColor.yellow |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -235,7 +257,7 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
file = file.appendingPathExtension("mp4") |
|
|
file = file.appendingPathExtension("mp4") |
|
|
} |
|
|
} |
|
|
print (file) |
|
|
print (file) |
|
|
var dur = loopEnd - loopStart |
|
|
|
|
|
|
|
|
var dur = player.loopEnd - loopStart |
|
|
if (dur < 0) { |
|
|
if (dur < 0) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
@ -278,45 +300,31 @@ class VideoController: UIViewController, ItemController, BMPlayerDelegate { |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if player.isPlayToTheEnd { |
|
|
if player.isPlayToTheEnd { |
|
|
player.seek(0, completion: {[weak self] in |
|
|
|
|
|
self!.player.play() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
player.seekSmoothlyToTime(newChaseTime: 0) |
|
|
player.isPlayToTheEnd = false |
|
|
player.isPlayToTheEnd = false |
|
|
} |
|
|
} |
|
|
player.play() |
|
|
player.play() |
|
|
} |
|
|
} |
|
|
print("play") |
|
|
|
|
|
|
|
|
print("play") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc func loop(_ sender: AnyObject) { |
|
|
@objc func loop(_ sender: AnyObject) { |
|
|
loopOption += 1 |
|
|
|
|
|
if loopOption >= 2 { |
|
|
|
|
|
loopOption = 0 |
|
|
|
|
|
|
|
|
if edit { |
|
|
|
|
|
loopMode = false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if loopOption == 1 { |
|
|
|
|
|
let t = player.playerLayer!.player!.currentTime() |
|
|
|
|
|
loopEnd = (Double(t.value) / Double(t.timescale)) - 2.0 |
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
loopMode = !loopMode |
|
|
} |
|
|
} |
|
|
updateLoop() |
|
|
updateLoop() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func updateLoop() { |
|
|
func updateLoop() { |
|
|
if loopOption == 1 { |
|
|
|
|
|
var dur = loopEnd - loopStart |
|
|
|
|
|
|
|
|
|
|
|
if dur > 0 { |
|
|
|
|
|
loopButton!.title = "(\(dur))" |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
loopButton!.title = "cont" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if loopMode { |
|
|
|
|
|
loopButton!.title = "loop" |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
loopButton!.title = "loop" |
|
|
|
|
|
|
|
|
loopButton!.title = "cont" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc func aspect(_ sender: AnyObject) { |
|
|
@objc func aspect(_ sender: AnyObject) { |
|
|
@ -325,9 +333,9 @@ print("play") |
|
|
aspect = 1 |
|
|
aspect = 1 |
|
|
} |
|
|
} |
|
|
switch aspect { |
|
|
switch aspect { |
|
|
case 1: |
|
|
|
|
|
player.aspectx = 1.0 |
|
|
|
|
|
player.aspecty = 1.0 |
|
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
player.aspectx = 1.0 |
|
|
|
|
|
player.aspecty = 1.0 |
|
|
case 2: |
|
|
case 2: |
|
|
player.aspectx = 0.9 |
|
|
player.aspectx = 0.9 |
|
|
player.aspecty = 1.0 |
|
|
player.aspecty = 1.0 |
|
|
@ -337,7 +345,7 @@ print("play") |
|
|
default: |
|
|
default: |
|
|
print("aspect") |
|
|
print("aspect") |
|
|
} |
|
|
} |
|
|
// todo player.verticalMoved(0) |
|
|
|
|
|
|
|
|
// todo player.verticalMoved(0) |
|
|
player.transformLayer() |
|
|
player.transformLayer() |
|
|
aspectButton!.title = "\(aspect)" |
|
|
aspectButton!.title = "\(aspect)" |
|
|
} |
|
|
} |
|
|
@ -388,7 +396,7 @@ print("play") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
let asset = BMPlayerResource(name: "video", definitions: def) |
|
|
let asset = BMPlayerResource(name: "video", definitions: def) |
|
|
// let asset = BMPlayerResource(url: url) |
|
|
|
|
|
|
|
|
// let asset = BMPlayerResource(url: url) |
|
|
|
|
|
|
|
|
player.setVideo(resource: asset, definitionIndex: index) |
|
|
player.setVideo(resource: asset, definitionIndex: index) |
|
|
player.playerLayer!.player!.automaticallyWaitsToMinimizeStalling = false |
|
|
player.playerLayer!.player!.automaticallyWaitsToMinimizeStalling = false |
|
|
@ -400,8 +408,8 @@ print("play") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func playerItemDidReachEnd(_ note: Notification) { |
|
|
func playerItemDidReachEnd(_ note: Notification) { |
|
|
print("finish") |
|
|
|
|
|
// Timer.scheduledTimer(timeInterval: 0.6, target: self, selector: #selector(update), userInfo: nil, repeats: false) |
|
|
|
|
|
|
|
|
print("finish") |
|
|
|
|
|
// Timer.scheduledTimer(timeInterval: 0.6, target: self, selector: #selector(update), userInfo: nil, repeats: false) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -439,52 +447,62 @@ print("finish") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc func thumbnailClicked(_ source: UIButton) { |
|
|
@objc func thumbnailClicked(_ source: UIButton) { |
|
|
currentSnapshot = buttons[source] |
|
|
|
|
|
player.seek(buttons[source]!.time) |
|
|
|
|
|
loopStart = buttons[source]!.time |
|
|
|
|
|
loopOption = 0 |
|
|
|
|
|
loopButton!.title = "loop" |
|
|
|
|
|
|
|
|
if let currentSnapshot = buttons[source] { |
|
|
|
|
|
gotoSnapshot(currentSnapshot: currentSnapshot) |
|
|
|
|
|
|
|
|
if (edit) { |
|
|
|
|
|
// editItem() |
|
|
|
|
|
|
|
|
if (edit) { |
|
|
|
|
|
editItem() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// moviePlayer!.currentPlaybackRate = Float(speedOptions[speedOption]) |
|
|
|
|
|
|
|
|
|
|
|
// print("goto \(buttons[source]!.time!) is \(moviePlayer!.currentPlaybackTime)") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func gotoSnapshot(currentSnapshot: MediaItem) { |
|
|
|
|
|
player.seekSmoothlyToTime(newChaseTime: currentSnapshot.time) |
|
|
|
|
|
loopStart = currentSnapshot.time |
|
|
|
|
|
player.loopEnd = loopStart + currentSnapshot.length |
|
|
|
|
|
|
|
|
|
|
|
if loopMode && currentSnapshot.scale > 0 { |
|
|
|
|
|
player.zoom = Float(currentSnapshot.scale) |
|
|
|
|
|
player.xpos = currentSnapshot.offset.x |
|
|
|
|
|
player.ypos = currentSnapshot.offset.y |
|
|
|
|
|
player.transformLayer() |
|
|
} |
|
|
} |
|
|
// moviePlayer!.currentPlaybackRate = Float(speedOptions[speedOption]) |
|
|
|
|
|
|
|
|
|
|
|
// print("goto \(buttons[source]!.time!) is \(moviePlayer!.currentPlaybackTime)") |
|
|
|
|
|
|
|
|
self.currentSnapshot = currentSnapshot |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc func update() { |
|
|
@objc func update() { |
|
|
|
|
|
|
|
|
reviewButton!.title = currentItem!.name |
|
|
|
|
|
|
|
|
reviewButton!.title = currentItem!.name |
|
|
|
|
|
|
|
|
if currentItem!.type == ItemType.SNAPSHOT { |
|
|
|
|
|
player.seek(currentItem!.time) |
|
|
|
|
|
if detailDelegate!.settings().autoloop && currentItem!.loop { |
|
|
|
|
|
loopStart = currentItem!.time |
|
|
|
|
|
loopEnd = currentItem!.time + currentItem!.length |
|
|
|
|
|
loopOption = 1 |
|
|
|
|
|
} |
|
|
|
|
|
currentItem = currentItem!.parent |
|
|
|
|
|
} else { |
|
|
|
|
|
if !currentItem!.children.isEmpty { |
|
|
|
|
|
player.seek(currentItem!.children[0].time) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
let duration = player.playerLayer!.playerItem!.duration |
|
|
|
|
|
if !duration.isIndefinite { |
|
|
|
|
|
print(duration) |
|
|
|
|
|
player.seek(duration.seconds / 2.0) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if currentItem!.type == ItemType.SNAPSHOT { |
|
|
|
|
|
player.seek(currentItem!.time) |
|
|
|
|
|
loopStart = currentItem!.time |
|
|
|
|
|
player.loopEnd = currentItem!.time + currentItem!.length |
|
|
|
|
|
currentItem = currentItem!.parent |
|
|
|
|
|
} else { |
|
|
|
|
|
if !currentItem!.children.isEmpty { |
|
|
|
|
|
player.seekSmoothlyToTime(newChaseTime: currentItem!.children[0].time) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
let duration = player.playerLayer!.playerItem!.duration |
|
|
|
|
|
if !duration.isIndefinite { |
|
|
|
|
|
print(duration) |
|
|
|
|
|
player.seekSmoothlyToTime(newChaseTime: duration.seconds / 2.0) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
navigationItem.rightBarButtonItems = [barbutton!] |
|
|
|
|
|
|
|
|
navigationItem.rightBarButtonItems = [barbutton!] |
|
|
|
|
|
|
|
|
for c in currentItem!.children { |
|
|
|
|
|
addItemButton(c) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for c in currentItem!.children { |
|
|
|
|
|
addItemButton(c) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
player.play() |
|
|
|
|
|
|
|
|
player.play() |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -535,38 +553,38 @@ print("finish") |
|
|
|
|
|
|
|
|
@objc func swipeUp() { |
|
|
@objc func swipeUp() { |
|
|
print("u") |
|
|
print("u") |
|
|
print("Type: \(currentItem!.type) Count: \(currentItem!.children.count) Index: \(index) Current: \(currentItem!.index)") |
|
|
|
|
|
|
|
|
print("Type: \(currentItem!.type) Count: \(currentItem!.children.count) Index: \(index) Current: \(currentItem!.index)") |
|
|
|
|
|
|
|
|
if !edit && (currentItem!.children.isEmpty || !(index < currentItem!.children.count - 1)) { |
|
|
|
|
|
print ("switch") |
|
|
|
|
|
var newIndex = currentItem!.index + 1 |
|
|
|
|
|
|
|
|
if !edit && (currentItem!.children.isEmpty || !(index < currentItem!.children.count - 1)) { |
|
|
|
|
|
print ("switch") |
|
|
|
|
|
var newIndex = currentItem!.index + 1 |
|
|
|
|
|
|
|
|
if currentItem!.parent!.children.count <= newIndex { |
|
|
|
|
|
newIndex = 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if currentItem!.parent!.children.count <= newIndex { |
|
|
|
|
|
newIndex = 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
currentItem = currentItem!.parent!.children[newIndex] |
|
|
|
|
|
|
|
|
currentItem = currentItem!.parent!.children[newIndex] |
|
|
|
|
|
|
|
|
print("'Switched Type: \(currentItem!.type) Count: \(currentItem!.children.count) Index: \(index) Current: \(currentItem!.index)") |
|
|
|
|
|
|
|
|
print("'Switched Type: \(currentItem!.type) Count: \(currentItem!.children.count) Index: \(index) Current: \(currentItem!.index)") |
|
|
|
|
|
|
|
|
index = 0 |
|
|
|
|
|
// player.playWithURL(currentItem!.playerURL) |
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 1.2, target: self, selector: #selector(update), userInfo: nil, repeats: false) |
|
|
|
|
|
|
|
|
index = 0 |
|
|
|
|
|
// player.playWithURL(currentItem!.playerURL) |
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 1.2, target: self, selector: #selector(update), userInfo: nil, repeats: false) |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if !(currentItem!.children.isEmpty) { |
|
|
|
|
|
print ("switch internal") |
|
|
|
|
|
if index < currentItem!.children.count - 1 { |
|
|
|
|
|
index+=1; |
|
|
|
|
|
} else { |
|
|
|
|
|
index = 0; |
|
|
|
|
|
} |
|
|
|
|
|
let child = currentItem!.children[index] |
|
|
|
|
|
// player.currentPlaybackTime = child.time! |
|
|
|
|
|
// player.currentPlaybackRate = Float(speedOptions[speedOption]) |
|
|
|
|
|
|
|
|
if !(currentItem!.children.isEmpty) { |
|
|
|
|
|
print ("switch internal") |
|
|
|
|
|
if index < currentItem!.children.count - 1 { |
|
|
|
|
|
index+=1; |
|
|
|
|
|
} else { |
|
|
|
|
|
index = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
let child = currentItem!.children[index] |
|
|
|
|
|
// player.currentPlaybackTime = child.time! |
|
|
|
|
|
// player.currentPlaybackRate = Float(speedOptions[speedOption]) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -585,28 +603,28 @@ print("finish") |
|
|
|
|
|
|
|
|
@objc func swipeDown() { |
|
|
@objc func swipeDown() { |
|
|
print("d") |
|
|
print("d") |
|
|
if !edit { |
|
|
|
|
|
var newIndex = currentItem!.index - 1 |
|
|
|
|
|
|
|
|
if !edit { |
|
|
|
|
|
var newIndex = currentItem!.index - 1 |
|
|
|
|
|
|
|
|
if newIndex < 0 { |
|
|
|
|
|
newIndex = 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if newIndex < 0 { |
|
|
|
|
|
newIndex = 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
currentItem = currentItem!.parent!.children[newIndex] |
|
|
|
|
|
index = 0; |
|
|
|
|
|
|
|
|
currentItem = currentItem!.parent!.children[newIndex] |
|
|
|
|
|
index = 0; |
|
|
|
|
|
|
|
|
// player.contentURL = currentItem!.playerURL |
|
|
|
|
|
player.play() |
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 1.2, target: self, selector: #selector(update), userInfo: nil, repeats: false) |
|
|
|
|
|
|
|
|
// player.contentURL = currentItem!.playerURL |
|
|
|
|
|
player.play() |
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 1.2, target: self, selector: #selector(update), userInfo: nil, repeats: false) |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
// player.currentPlaybackTime = player.currentPlaybackTime + 10.0 |
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 0.9, |
|
|
|
|
|
target: self, |
|
|
|
|
|
selector: #selector(resumePlay), |
|
|
|
|
|
userInfo: nil, |
|
|
|
|
|
repeats: false) |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
// player.currentPlaybackTime = player.currentPlaybackTime + 10.0 |
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 0.9, |
|
|
|
|
|
target: self, |
|
|
|
|
|
selector: #selector(resumePlay), |
|
|
|
|
|
userInfo: nil, |
|
|
|
|
|
repeats: false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@ -615,11 +633,11 @@ print("finish") |
|
|
print("l") |
|
|
print("l") |
|
|
// player.currentPlaybackRate = Float(0.0) |
|
|
// player.currentPlaybackRate = Float(0.0) |
|
|
// player.currentPlaybackTime = player.currentPlaybackTime + 30.0 |
|
|
// player.currentPlaybackTime = player.currentPlaybackTime + 30.0 |
|
|
Timer.scheduledTimer(timeInterval: 0.9, |
|
|
|
|
|
target: self, |
|
|
|
|
|
selector: #selector(resumePlay), |
|
|
|
|
|
userInfo: nil, |
|
|
|
|
|
repeats: false) |
|
|
|
|
|
|
|
|
Timer.scheduledTimer(timeInterval: 0.9, |
|
|
|
|
|
target: self, |
|
|
|
|
|
selector: #selector(resumePlay), |
|
|
|
|
|
userInfo: nil, |
|
|
|
|
|
repeats: false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@ -645,7 +663,7 @@ print("finish") |
|
|
} catch let error { |
|
|
} catch let error { |
|
|
print("*** Error generating thumbnail: \(error.localizedDescription)") |
|
|
print("*** Error generating thumbnail: \(error.localizedDescription)") |
|
|
} |
|
|
} |
|
|
// thumbnailTime = player.currentPlaybackTime |
|
|
|
|
|
|
|
|
// thumbnailTime = player.currentPlaybackTime |
|
|
print("tap \(thumbnailTime)") |
|
|
print("tap \(thumbnailTime)") |
|
|
// moviePlayer!.requestThumbnailImages(atTimes: [thumbnailTime], |
|
|
// moviePlayer!.requestThumbnailImages(atTimes: [thumbnailTime], |
|
|
// timeOption: MPMovieTimeOption.exact); |
|
|
// timeOption: MPMovieTimeOption.exact); |
|
|
@ -667,6 +685,61 @@ print("finish") |
|
|
|
|
|
|
|
|
addItemButton(newItem) |
|
|
addItemButton(newItem) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func moveUp() { |
|
|
|
|
|
let t = Date().timeIntervalSince1970 |
|
|
|
|
|
if lastMove + 2 > t { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
lastMove = t |
|
|
|
|
|
|
|
|
|
|
|
if let c = currentItem?.children { |
|
|
|
|
|
if !c.isEmpty{ |
|
|
|
|
|
if let s = currentSnapshot { |
|
|
|
|
|
if var i = c.firstIndex { x in x===s } { |
|
|
|
|
|
print(i) |
|
|
|
|
|
i+=1 |
|
|
|
|
|
if i >= c.count { |
|
|
|
|
|
i = 0 |
|
|
|
|
|
} |
|
|
|
|
|
gotoSnapshot(currentSnapshot: c[i]) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
gotoSnapshot(currentSnapshot: c[0]) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var lastMove = 0.0 |
|
|
|
|
|
|
|
|
|
|
|
func moveDown() { |
|
|
|
|
|
let t = Date().timeIntervalSince1970 |
|
|
|
|
|
if lastMove + 2 > t { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
lastMove = t |
|
|
|
|
|
|
|
|
|
|
|
if let c = currentItem?.children { |
|
|
|
|
|
if !c.isEmpty{ |
|
|
|
|
|
if let s = currentSnapshot { |
|
|
|
|
|
if var i = c.firstIndex { x in x===s } { |
|
|
|
|
|
print(i) |
|
|
|
|
|
i-=1 |
|
|
|
|
|
if i < 0 { |
|
|
|
|
|
i = c.count-1 |
|
|
|
|
|
} |
|
|
|
|
|
gotoSnapshot(currentSnapshot: c[i]) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
gotoSnapshot(currentSnapshot: c[0]) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func bmPlayer(player: BMPlayer) { |
|
|
func bmPlayer(player: BMPlayer) { |
|
|
let speed = Float(speedOptions[speedOption]) |
|
|
let speed = Float(speedOptions[speedOption]) |
|
|
if let pl = player.playerLayer!.player { |
|
|
if let pl = player.playerLayer!.player { |
|
|
@ -680,16 +753,20 @@ print("finish") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func bmPlayer(player: BMPlayer, loadedTimeDidChange loadedDuration: TimeInterval, totalDuration: TimeInterval) { |
|
|
func bmPlayer(player: BMPlayer, loadedTimeDidChange loadedDuration: TimeInterval, totalDuration: TimeInterval) { |
|
|
// print("load") |
|
|
|
|
|
|
|
|
// print("load") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func bmPlayer(player: BMPlayer, playTimeDidChange currentTime: TimeInterval, totalTime: TimeInterval) { |
|
|
func bmPlayer(player: BMPlayer, playTimeDidChange currentTime: TimeInterval, totalTime: TimeInterval) { |
|
|
if loopOption == 1 { |
|
|
|
|
|
if currentTime > loopEnd { |
|
|
|
|
|
player.seek(loopStart) |
|
|
|
|
|
|
|
|
if loopMode { |
|
|
|
|
|
if currentTime > player.loopEnd && loopStart < player.loopEnd { |
|
|
|
|
|
player.chaseTime = CMTime.zero |
|
|
|
|
|
player.seekSmoothlyToTime(newChaseTime: loopStart) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// print("Time") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let b = backButton { |
|
|
|
|
|
b.title = BMPlayer.formatSecondsToString(currentTime) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func bmPlayer(player: BMPlayer, playerIsPlaying playing: Bool) { |
|
|
func bmPlayer(player: BMPlayer, playerIsPlaying playing: Bool) { |
|
|
|