Play YT stream first if downloading
This commit is contained in:
parent
ce11918e4e
commit
46190a372b
@ -281,9 +281,9 @@ module.exports = [
|
|||||||
let dlData = cacheManager.read("download")[videoName]
|
let dlData = cacheManager.read("download")[videoName]
|
||||||
|
|
||||||
let status = "not found"
|
let status = "not found"
|
||||||
if (videoName && videoName != "" && downloader.videoExists(videoName)) {
|
if (videoName) {
|
||||||
// Case 1: not in memory but exists as a file. probably downloaded on a previous server run
|
// Case 1: not in memory but exists as a file. probably downloaded on a previous server run
|
||||||
if (dlData == undefined)
|
if (dlData == undefined && downloader.videoExists(videoName))
|
||||||
status = "found"
|
status = "found"
|
||||||
// Case 2: in memory
|
// Case 2: in memory
|
||||||
else if (dlData)
|
else if (dlData)
|
||||||
|
@ -255,7 +255,7 @@ module.exports = [
|
|||||||
if (!qSet && willDownload && !largestSavedFormat) {
|
if (!qSet && willDownload && !largestSavedFormat) {
|
||||||
dlQueue.enqueue(id, startingFormat.qualityLabel)
|
dlQueue.enqueue(id, startingFormat.qualityLabel)
|
||||||
// Wait for a second to give the default noscript player at least a small portion of bytes to play
|
// Wait for a second to give the default noscript player at least a small portion of bytes to play
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
// await new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only preload if new quality is better than what we already have, unless using &quality
|
// Only preload if new quality is better than what we already have, unless using &quality
|
||||||
|
@ -11,8 +11,10 @@ Promise.all(modulePaths.map(m => import(`/static/js/player/${m}.js`))).then(modu
|
|||||||
modules[modulePaths[i]] = modules[modulePaths[i]].default(modules, q, qa)
|
modules[modulePaths[i]] = modules[modulePaths[i]].default(modules, q, qa)
|
||||||
|
|
||||||
// Page + all modules loaded
|
// Page + all modules loaded
|
||||||
|
if (modules.globals.awaitingNewFormat && !modules.globals.startingFormat.cloudtube__label.endsWith(" *"))
|
||||||
modules.quality.videoDownloaded(modules.globals.videoPath, modules.globals.startingFormat.qualityLabel)
|
modules.quality.setVideoSource(modules.globals.videoPath, true)
|
||||||
|
else
|
||||||
|
modules.quality.videoDownloaded(modules.globals.videoPath, modules.globals.startingFormat.qualityLabel, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Hide default controls
|
// Hide default controls
|
||||||
|
@ -96,8 +96,9 @@ export default (modules, q, qa) => {
|
|||||||
waitForNewVideoLoad: (videoName, quality) => {
|
waitForNewVideoLoad: (videoName, quality) => {
|
||||||
modules.cacheInfo.pingCache(`${videoName}-${quality}`, () => self.videoDownloaded(`/getVideo?v=${videoName}&q=${quality}`, quality), 1000 * 3)
|
modules.cacheInfo.pingCache(`${videoName}-${quality}`, () => self.videoDownloaded(`/getVideo?v=${videoName}&q=${quality}`, quality), 1000 * 3)
|
||||||
},
|
},
|
||||||
setVideoSource: newSource => {
|
setVideoSource: (newSource, dontReload) => {
|
||||||
videoSource = newSource
|
videoSource = newSource
|
||||||
|
if (!dontReload)
|
||||||
self.reloadSource()
|
self.reloadSource()
|
||||||
},
|
},
|
||||||
videoDownloaded: (videoName, quality) => {
|
videoDownloaded: (videoName, quality) => {
|
||||||
|
@ -60,7 +60,7 @@ block content
|
|||||||
if targetFormat
|
if targetFormat
|
||||||
.video-container-inner
|
.video-container-inner
|
||||||
video(controls playsinline preload="auto" width=targetFormat.second__width height=targetFormat.second__height data-itag=targetFormat.itag autoplay=continuous||autoplay).video
|
video(controls playsinline preload="auto" width=targetFormat.second__width height=targetFormat.second__height data-itag=targetFormat.itag autoplay=continuous||autoplay).video
|
||||||
source(type=targetFormat.type src=`${videoPath}${mediaFragment}`)
|
source(type=targetFormat.type src=(dlStatus < 2 ? startingFormat.url : `${videoPath}${mediaFragment}`))
|
||||||
//- source(type=targetFormat.type)
|
//- source(type=targetFormat.type)
|
||||||
each t in video.captions
|
each t in video.captions
|
||||||
track(label=t.label kind="subtitles" srclang=t.languageCode src=t.url)
|
track(label=t.label kind="subtitles" srclang=t.languageCode src=t.url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user