#63535 Поддержка Chromecast

This commit is contained in:
Алексей Манаев
2025-07-11 09:46:07 +00:00
parent c19d40fcf0
commit 60e3f33356
7 changed files with 33 additions and 38 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
node_modules
npm-debug.log
distribution
vendors
distribution
+2
View File
@@ -2,6 +2,8 @@
FROM arm64v8/node:23.6.1-alpine3.21 AS arm
#FROM node:23.6.1-alpine3.21 AS intel
RUN apk add git
# Global npm dependencies for correct caching docker layers
RUN <<EOF
npm install @swc/core -D;
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# Start nodemon
nodemon --watch src --watch vendors -e ts --exec npm run build &
nodemon --watch src --watch vendors -e ts,js,scss --exec npm run build &
# Start lite-server
lite-server -c configs/lite-server-config.json
+9 -9
View File
@@ -25,14 +25,14 @@
"srt-parser-2": "^1.2.3",
"ts-bus": "^2.3.1",
"ts-node": "^10.9.2",
"tsup": "^8.3.6",
"tsup": "8.3.6",
"typescript": "^5.7.3",
"ua-parser-js": "^0.7.38"
},
"devDependencies": {
"@swc/core": "^1.11.20",
"terser": "^5.37.0",
"video.js": "^8.21.0"
"video.js": "^8.23.3"
}
},
"node_modules/@babel/runtime": {
@@ -2451,9 +2451,9 @@
}
},
"node_modules/@videojs/http-streaming": {
"version": "3.16.2",
"resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-3.16.2.tgz",
"integrity": "sha512-fvt4ko7FknxiT9FnjyNQt6q2px+awrkM+Orv7IB/4gldvj94u4fowGfmNHynnvNTPgPkdxHklGmFLGfclYw8HA==",
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-3.17.0.tgz",
"integrity": "sha512-Ch1P3tvvIEezeZXyK11UfWgp4cWKX4vIhZ30baN/lRinqdbakZ5hiAI3pGjRy3d+q/Epyc8Csz5xMdKNNGYpcw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
@@ -6377,14 +6377,14 @@
}
},
"node_modules/video.js": {
"version": "8.21.0",
"resolved": "https://registry.npmjs.org/video.js/-/video.js-8.21.0.tgz",
"integrity": "sha512-zcwerRb257QAuWfi8NH9yEX7vrGKFthjfcONmOQ4lxFRpDAbAi+u5LAjCjMWqhJda6zEmxkgdDpOMW3Y21QpXA==",
"version": "8.23.3",
"resolved": "https://registry.npmjs.org/video.js/-/video.js-8.23.3.tgz",
"integrity": "sha512-Toe0VLlDZcUhiaWfcePS1OEdT3ATfktm0hk/PELfD7zUoPDHeT+cJf/wZmCy5M5eGVwtGUg25RWPCj1L/1XufA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@videojs/http-streaming": "^3.16.2",
"@videojs/http-streaming": "^3.17.0",
"@videojs/vhs-utils": "^4.1.1",
"@videojs/xhr": "2.7.0",
"aes-decrypter": "^4.0.2",
+1 -1
View File
@@ -32,7 +32,7 @@
"srt-parser-2": "^1.2.3",
"ts-bus": "^2.3.1",
"ts-node": "^10.9.2",
"tsup": "^8.3.6",
"tsup": "8.3.6",
"typescript": "^5.7.3",
"ua-parser-js": "^0.7.38"
},
+1 -1
View File
@@ -4,7 +4,7 @@
@use "../scss/utilities";
// External Components
@use "~@silvermine/videojs-chromecast/src/scss/videojs-chromecast";
@use "@silvermine/videojs-chromecast/src/scss/videojs-chromecast";
// Components
@use "../scss/components/layout";
@@ -219,30 +219,12 @@ module.exports = function(videojs) {
castSession.loadMedia(request)
.then(function() {
this._clearSessionTimeout();
if (!this._hasPlayedAnyItem) {
// `triggerReady` is required here to notify the Video.js
// player that the Tech has been initialized and is ready.
this.triggerReady();
}
this.trigger('loadstart');
this.trigger('loadeddata');
this.trigger('play');
this.trigger('playing');
this._hasPlayedAnyItem = true;
this._isMediaLoading = false;
// 🔁 Добавлено отложенное выполнение
setTimeout(() => {
const mediaSession = this._getMediaSession();
if (mediaSession) {
mediaSession.addUpdateListener(this._onMediaSessionStatusChanged.bind(this));
} else {
console.warn('⚠️ MediaSession is still null after loadMedia');
}
}, 0);
}.bind(this), this._triggerErrorEvent.bind(this));
}
@@ -643,19 +625,31 @@ module.exports = function(videojs) {
var states = chrome.cast.media.PlayerState,
playerState = this._remotePlayer.playerState;
const mediaSession = this._getMediaSession();
if (mediaSession && !this._hasPlayedAnyItem && this._isMediaLoading) {
this._hasPlayedAnyItem = true;
this._isMediaLoading = false;
mediaSession.addUpdateListener(this._onMediaSessionStatusChanged.bind(this));
console.log('chromecast: mediaSession is ready');
this.setTimeout(() => { this.trigger('loadeddata') } );
// Откладываем отправку canplay чтобы videojs успел обновить состояение isReady_ = true и
// changingSrc_ = false, иначе не будет передана текущая позиция воспроизведения в приемник.
this.setTimeout(() => { this.trigger('canplay') }, 50);
}
if (playerState === states.PLAYING) {
this._hasPlayedCurrentItem = true;
this.trigger('play');
this.trigger('playing');
this.setTimeout(() => { this.trigger('play') } );
this.setTimeout(() => { this.trigger('playing') } );
} else if (playerState === states.PAUSED) {
this.trigger('pause');
this.setTimeout(() => { this.trigger('pause') });
} else if ((playerState === states.IDLE && this.ended()) || (playerState === null && this._hasPlayedCurrentItem)) {
this._hasPlayedCurrentItem = false;
this._closeSessionOnTimeout();
this.trigger('ended');
this._triggerTimeUpdateEvent();
this.setTimeout(() => { this.trigger('ended') } );
this.setTimeout(() => { this._triggerTimeUpdateEvent() } );
} else if (playerState === states.BUFFERING) {
this.trigger('waiting');
this.setTimeout(() => { this.trigger('waiting') } );
}
}