Fix incompatible DASH stream bug
This commit is contained in:
1 parent
3bdf2cfb14
commit
80d169f386
2 files changed
+50
-24
No files matched your search
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Bug where app freezes if metadata fails to fetch
|
- Bug where app freezes if metadata fails to fetch
|
||||||
- Bug where SponsorBlock returning videoDuration of zero causes the app to hang
|
- Bug where SponsorBlock returning videoDuration of zero causes the app to hang
|
||||||
- Bug where app would lose focus when casting from web app
|
- Bug where app would lose focus when casting from web app
|
||||||
|
- Bug where DASH stream is not compatible. Play format stream as a fallback
|
||||||
|
|
||||||
## [0.5.0] - 2022-12-02
|
## [0.5.0] - 2022-12-02
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -82,28 +82,53 @@ function OnVideoDetailsTaskResults() as void
|
|||||||
|
|
||||||
metadata = metadata.data
|
metadata = metadata.data
|
||||||
|
|
||||||
contentNode = CreateObject("roSGNode", "ContentNode")
|
playletStreamUrls = []
|
||||||
contentNode.addFields({ metadata: metadata })
|
|
||||||
|
|
||||||
if metadata.hlsUrl <> invalid
|
if metadata.hlsUrl <> invalid
|
||||||
contentNode.url = metadata.hlsUrl
|
playletStreamUrls.push(metadata.hlsUrl)
|
||||||
else if metadata.dashUrl <> invalid
|
|
||||||
#if DASH_THUMBNAILS
|
|
||||||
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
|
||||||
contentNode.url = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
|
||||||
#else
|
|
||||||
contentNode.url = metadata.dashUrl
|
|
||||||
#end if
|
|
||||||
else
|
else
|
||||||
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
|
if metadata.dashUrl <> invalid
|
||||||
itag = stream.itag
|
|
||||||
' Use an url relative to the host, so we can proxy(local=true) in case it fails
|
#if DASH_THUMBNAILS
|
||||||
contentNode.url = Invidious.GetVideoUrl(videoId, itag, false)
|
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
||||||
|
dashUrl = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
||||||
|
#else
|
||||||
|
dashUrl = metadata.dashUrl
|
||||||
|
#end if
|
||||||
|
playletStreamUrls.push(dashUrl)
|
||||||
|
|
||||||
|
if dashUrl.InStr("?") = -1
|
||||||
|
dashUrlLocal = dashUrl + "?local=true"
|
||||||
|
else
|
||||||
|
dashUrlLocal = dashUrl + "&local=true"
|
||||||
|
end if
|
||||||
|
playletStreamUrls.push(dashUrlLocal)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if metadata.formatStreams.Count() > 0
|
||||||
|
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
|
||||||
|
itag = stream.itag
|
||||||
|
streamUrl = Invidious.GetVideoUrl(videoId, itag, false)
|
||||||
|
playletStreamUrls.push(streamUrl)
|
||||||
|
if streamUrl.InStr("?") = -1
|
||||||
|
streamUrlLocal = streamUrl + "?local=true"
|
||||||
|
else
|
||||||
|
streamUrlLocal = streamUrl + "&local=true"
|
||||||
|
end if
|
||||||
|
playletStreamUrls.push(streamUrlLocal)
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
metadata.playletStreamUrls = playletStreamUrls
|
||||||
|
metadata.playletStreamUrlIndex = 0
|
||||||
|
|
||||||
|
contentNode = CreateObject("roSGNode", "ContentNode")
|
||||||
|
contentNode.addFields({ metadata: metadata })
|
||||||
|
|
||||||
contentNode.title = metadata.title
|
contentNode.title = metadata.title
|
||||||
contentNode.secondaryTitle = metadata.author
|
contentNode.secondaryTitle = metadata.author
|
||||||
SetCaptions(metadata, m.top, contentNode)
|
SetCaptions(metadata, m.top, contentNode)
|
||||||
|
contentNode.url = metadata.playletStreamUrls[metadata.playletStreamUrlIndex]
|
||||||
m.busySpinner.visible = false
|
m.busySpinner.visible = false
|
||||||
m.busySpinner.control = "stop"
|
m.busySpinner.control = "stop"
|
||||||
m.top.content = contentNode
|
m.top.content = contentNode
|
||||||
@@ -203,15 +228,15 @@ function OnVideoPlayerStateChange() as void
|
|||||||
errorInfo = m.top.errorInfo
|
errorInfo = m.top.errorInfo
|
||||||
' http for stream format, mediaerror for DASH
|
' http for stream format, mediaerror for DASH
|
||||||
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
|
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
|
||||||
url = m.top.content.url
|
currentUrl = m.top.content.metadata.playletStreamUrls[m.top.content.metadata.playletStreamUrlIndex]
|
||||||
if url.InStr("local=true") = -1
|
metadata = m.top.content.metadata
|
||||||
print(`Video ${url} failed to play. Trying a proxy (local=true)`)
|
metadata.playletStreamUrlIndex++
|
||||||
if url.InStr("?") = -1
|
m.top.content.metadata = metadata
|
||||||
url += "?local=true"
|
if m.top.content.metadata.playletStreamUrlIndex < m.top.content.metadata.playletStreamUrls.Count()
|
||||||
else
|
nextUrl = m.top.content.metadata.playletStreamUrls[m.top.content.metadata.playletStreamUrlIndex]
|
||||||
url += "&local=true"
|
print(`Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`)
|
||||||
end if
|
|
||||||
m.top.content.url = url
|
m.top.content.url = nextUrl
|
||||||
' This video errored, and is about to finish, so don't close the video yet
|
' This video errored, and is about to finish, so don't close the video yet
|
||||||
' TODO: perhaps creating a second player is better?
|
' TODO: perhaps creating a second player is better?
|
||||||
m.ignoreNextFinishedState = true
|
m.ignoreNextFinishedState = true
|
||||||
@@ -229,7 +254,7 @@ function OnVideoPlayerStateChange() as void
|
|||||||
|
|
||||||
if state = "finished"
|
if state = "finished"
|
||||||
metadata = m.top.content?.metadata
|
metadata = m.top.content?.metadata
|
||||||
videoId = metadata?.recommendedVideos?[0]?.videoId
|
videoId = metadata?.recommendedVideos?.GetEntry(0)?.videoId
|
||||||
if videoId <> invalid
|
if videoId <> invalid
|
||||||
PlayVideo(videoId, invalid)
|
PlayVideo(videoId, invalid)
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user