From d1af22629f08ad9d6abc60fdd037025c8882549c Mon Sep 17 00:00:00 2001 From: unclekingpin <125216544+unclekingpin@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:13:46 +0200 Subject: [PATCH] Streaming server can play (#48) * check if at least 1 audio/video stream is supported * 0.0.25-rc.3 * update node * add webm format * 0.0.25-rc.4 * update media capabilities detection * force stereo audio on chrome * force stereo audio on chromecast * revert formatting * fix lint * override media capabilities with command args * fix lint * fix lint * fix lint * 0.0.25-rc.5 * remove merge with * revert format specific codec checks * reformat * revert changes in ss middleware * add support for mkv only in chrome * 0.0.25-rc.6 --- .github/workflows/publish.yml | 2 +- package.json | 2 +- src/mediaCapabilities.js | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 28f07e4..42be410 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,7 @@ jobs: - name: Setup NodeJS uses: actions/setup-node@v1 with: - node-version: 10 + node-version: 16 registry-url: https://registry.npmjs.org/ - name: Checkout uses: actions/checkout@v2 diff --git a/package.json b/package.json index 6183423..f26b37d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stremio/stremio-video", - "version": "0.0.25-rc.2", + "version": "0.0.25-rc.6", "description": "Abstraction layer on top of different media players", "author": "Smart Code OOD", "main": "src/index.js", diff --git a/src/mediaCapabilities.js b/src/mediaCapabilities.js index 4641e6f..79c349b 100644 --- a/src/mediaCapabilities.js +++ b/src/mediaCapabilities.js @@ -1,10 +1,12 @@ var VIDEO_CODEC_CONFIGS = [ { codec: 'h264', + force: window.chrome || window.cast, mime: 'video/mp4; codecs="avc1.42E01E"', }, { codec: 'h265', + force: window.chrome || window.cast, mime: 'video/mp4; codecs="hev1.1.6.L150.B0"', aliases: ['hevc'] }, @@ -46,10 +48,9 @@ var AUDIO_CODEC_CONFIGS = [ ]; function canPlay(config, options) { - return options.mediaElement.canPlayType(config.mime) ? - [config.codec].concat(config.aliases || []) - : - []; + return config.force || options.mediaElement.canPlayType(config.mime) + ? [config.codec].concat(config.aliases || []) + : []; } function getMaxAudioChannels() { @@ -57,7 +58,7 @@ function getMaxAudioChannels() { return 6; } - if (!window.AudioContext) { + if (!window.AudioContext || window.chrome || window.cast) { return 2; } @@ -68,6 +69,9 @@ function getMaxAudioChannels() { function getMediaCapabilities() { var mediaElement = document.createElement('video'); var formats = ['mp4']; + if (window.chrome || window.cast) { + formats.push('matroska,webm'); + } var videoCodecs = VIDEO_CODEC_CONFIGS .map(function(config) { return canPlay(config, { mediaElement: mediaElement });