mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 18:54:11 +00:00
Open videos via URL scheme
This commit is contained in:
@@ -27,17 +27,20 @@ extension PlayerModel {
|
||||
}
|
||||
}
|
||||
|
||||
func playNow(_ video: Video) {
|
||||
func playNow(_ video: Video, at time: TimeInterval? = nil) {
|
||||
addCurrentItemToHistory()
|
||||
|
||||
enqueueVideo(video, prepending: true) { _, item in
|
||||
self.advanceToItem(item)
|
||||
self.advanceToItem(item, at: time)
|
||||
}
|
||||
}
|
||||
|
||||
func playItem(_ item: PlayerQueueItem, video: Video? = nil) {
|
||||
func playItem(_ item: PlayerQueueItem, video: Video? = nil, at time: TimeInterval? = nil) {
|
||||
currentItem = item
|
||||
if currentItem.playbackTime.isNil {
|
||||
|
||||
if !time.isNil {
|
||||
currentItem.playbackTime = CMTime(seconds: time!, preferredTimescale: 1_000_000)
|
||||
} else if currentItem.playbackTime.isNil {
|
||||
currentItem.playbackTime = .zero
|
||||
}
|
||||
|
||||
@@ -45,7 +48,7 @@ extension PlayerModel {
|
||||
currentItem.video = video!
|
||||
}
|
||||
|
||||
playVideo(currentVideo!, time: item.playbackTime)
|
||||
playVideo(currentVideo!, time: currentItem.playbackTime)
|
||||
}
|
||||
|
||||
func advanceToNextItem() {
|
||||
@@ -56,12 +59,12 @@ extension PlayerModel {
|
||||
}
|
||||
}
|
||||
|
||||
func advanceToItem(_ newItem: PlayerQueueItem) {
|
||||
func advanceToItem(_ newItem: PlayerQueueItem, at time: TimeInterval? = nil) {
|
||||
addCurrentItemToHistory()
|
||||
|
||||
let item = remove(newItem)!
|
||||
loadDetails(newItem.video) { video in
|
||||
self.playItem(item, video: video)
|
||||
self.playItem(item, video: video, at: time)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,14 +32,16 @@ extension PlayerModel {
|
||||
|
||||
private func skip(_ segment: Segment, at time: CMTime) {
|
||||
guard segment.endTime.seconds <= playerItemDuration?.seconds ?? .infinity else {
|
||||
logger.error("item time is: \(time.seconds) and trying to skip to \(playerItemDuration?.seconds ?? .infinity)")
|
||||
logger.error(
|
||||
"segment end time is: \(segment.end) when player item duration is: \(playerItemDuration?.seconds ?? .infinity)"
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
player.seek(to: segment.endTime)
|
||||
lastSkipped = segment
|
||||
segmentRestorationTime = time
|
||||
logger.info("SponsorBlock skipping to: \(segment.endTime)")
|
||||
logger.info("SponsorBlock skipping to: \(segment.end)")
|
||||
}
|
||||
|
||||
private func shouldSkip(_ segment: Segment, at time: CMTime) -> Bool {
|
||||
|
Reference in New Issue
Block a user