From 55c0e7e8c564fbd10db636144079b17c75f4fdd4 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 5 Jan 2025 02:47:45 +0100 Subject: [PATCH] Get DRM status to UI more reliably --- src/csui/PlayerOverlay.vue | 8 ++++++-- src/ext/lib/ar-detect/DrmDetecor.ts | 4 ++-- src/ext/lib/video-data/VideoData.ts | 18 ++++++++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/csui/PlayerOverlay.vue b/src/csui/PlayerOverlay.vue index 7b07b01..0a26a46 100644 --- a/src/csui/PlayerOverlay.vue +++ b/src/csui/PlayerOverlay.vue @@ -127,7 +127,7 @@
Autodetection potentially
- unavailable due to DRM. + unavailable due to DRM.
Autodetection blocked
@@ -327,6 +327,7 @@ export default { (data) => { switch (data.type) { case 'drm-status': + console.log('got DRM status!'); this.statusFlags.hasDrm = data.hasDrm; break; case 'aard-error': @@ -493,6 +494,9 @@ export default { preventContextMenuHide() { this.contextMenuActive = true; + + // refresh DRM status + this.eventBus.sendToTunnel('get-drm-status'); }, allowContextMenuHide() { this.contextMenuActive = false; @@ -511,7 +515,7 @@ export default { this.allowContextMenuHide(); // refresh DRM status - this.eventBus.send('get-drm-status'); + this.eventBus.sendToTunnel('get-drm-status'); // if (this.isGlobal) { // this.sendToParentLowLevel('uwui-clickable', undefined, {clickable: true}); diff --git a/src/ext/lib/ar-detect/DrmDetecor.ts b/src/ext/lib/ar-detect/DrmDetecor.ts index a7a2012..96de3d6 100644 --- a/src/ext/lib/ar-detect/DrmDetecor.ts +++ b/src/ext/lib/ar-detect/DrmDetecor.ts @@ -1,5 +1,5 @@ /** - * Checks whether video we're trying to play is protected by DRM. + * Checks whether video we're trying to play is protected by DRM. * @param {*} video video we're trying to check */ export function hasDrm(video) { @@ -9,4 +9,4 @@ export function hasDrm(video) { } return video.mediaKeys instanceof MediaKeys; -} \ No newline at end of file +} diff --git a/src/ext/lib/video-data/VideoData.ts b/src/ext/lib/video-data/VideoData.ts index a0daf00..7870a4c 100644 --- a/src/ext/lib/video-data/VideoData.ts +++ b/src/ext/lib/video-data/VideoData.ts @@ -146,7 +146,6 @@ class VideoData { async onVideoLoaded() { if (!this.videoLoaded) { - /** * video.readyState 101: * 0 — no info. Can't play. @@ -160,6 +159,12 @@ class VideoData { } this.logger.log('info', 'init', '%c[VideoData::onVideoLoaded] ——————————— Initiating phase two of videoData setup ———————————', 'color: #0f9'); + this.hasDrm = hasDrm(this.video); + this.eventBus.send( + 'uw-config-broadcast', { + type: 'drm-status', + hasDrm: this.hasDrm + }); this.videoLoaded = true; this.videoDimensionsLoaded = true; try { @@ -678,11 +683,12 @@ class VideoData { } try { - if (hasDrm(this.video)) { - this.hasDrm = true; - } else { - this.hasDrm = false; - } + this.hasDrm = !!hasDrm(this.video); + this.eventBus.send( + 'uw-config-broadcast', { + type: 'drm-status', + hasDrm: this.hasDrm + }); if (!this.aard) { this.initArDetection();