Skip to content

Commit

Permalink
Log video quality
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Nov 26, 2024
1 parent f5456e5 commit 7c2cb55
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions playlet-lib/src/components/VideoPlayer/VideoPlayer.bs
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7c2cb55

Please sign in to comment.