From 7c2cb5517a8c7220d76cc01fa7da9ed34420782e Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Tue, 26 Nov 2024 18:26:38 -0500 Subject: [PATCH] Log video quality --- CHANGELOG.md | 4 ++ .../src/components/VideoPlayer/VideoPlayer.bs | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aef92ce..31ced20b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Nothing worth mentioning yet. + ## [0.31.0] - 2024-11-24 ### Added diff --git a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs index 744fd240..c183179a 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs @@ -1,3 +1,5 @@ +#const DEBUG_LOG_VIDEO_QUALITY = false + import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs" import "pkg:/components/VideoPlayer/Lounge.bs" @@ -50,8 +52,49 @@ function Init() httpAgent = m.top.getHttpAgent() httpAgent.AddHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0") + + #if DEBUG_LOG_VIDEO_QUALITY + m.top.addFields({ + "_resolution": "" + "_audioFormat": "" + "_videoFormat": "" + }) + + m.top.observeField("streamingSegment", FuncName(OnStreamingSegmentChangeDebug)) + + m.top.observeField("audioFormat", FuncName(OnFormatChangeDebug)) + m.top.observeField("videoFormat", FuncName(OnFormatChangeDebug)) + m.top.observeField("_resolution", FuncName(OnFormatChangeDebug)) + + m.top.observeField("_audioFormat", FuncName(OnQualityChangeDebug)) + m.top.observeField("_videoFormat", FuncName(OnQualityChangeDebug)) + #end if end function +#if DEBUG_LOG_VIDEO_QUALITY + function OnStreamingSegmentChangeDebug() + segment = m.top.streamingSegment + width = segment.width + height = segment.height + if width > 0 and height > 0 + m.top._resolution = `${width}x${height}` + end if + end function + + function OnFormatChangeDebug() + audioFormat = m.top.audioFormat + videoFormat = m.top.videoFormat + resolution = m.top._resolution + + m.top._audioFormat = audioFormat + m.top._videoFormat = `${videoFormat} ${resolution}` + end function + + function OnQualityChangeDebug() + LogDebug("Video format:", m.top._videoFormat, "Audio format:", m.top._audioFormat) + end function +#end if + function OnNodeReady() minRect = m.top.minRect rect = m.container.fullscreen ? m.top.maxRect : minRect