From ef6e22b10fa3fe342549040aee4f764097944529 Mon Sep 17 00:00:00 2001 From: unclekingpin Date: Thu, 2 Nov 2023 14:35:45 -0700 Subject: [PATCH] revert formatting --- src/mediaCapabilities.js | 16 +++--- .../withStreamingServer.js | 56 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/mediaCapabilities.js b/src/mediaCapabilities.js index 10fce83..4248201 100644 --- a/src/mediaCapabilities.js +++ b/src/mediaCapabilities.js @@ -114,27 +114,27 @@ function getMediaCapabilities() { var maxAudioChannels = getMaxAudioChannels(); return { mp4: { - videoCodecs: MP4_CONFIG.VIDEO_CODECS.map(function (config) { + videoCodecs: MP4_CONFIG.VIDEO_CODECS.map(function(config) { return canPlay(config, { mediaElement: mediaElement }); - }).reduce(function (result, value) { + }).reduce(function(result, value) { return result.concat(value); }, []), - audioCodecs: MP4_CONFIG.AUDIO_CODEC.map(function (config) { + audioCodecs: MP4_CONFIG.AUDIO_CODEC.map(function(config) { return canPlay(config, { mediaElement: mediaElement }); - }).reduce(function (result, value) { + }).reduce(function(result, value) { return result.concat(value); }, []), maxAudioChannels, }, 'matroska,webm': { - videoCodecs: MATROSKA_CONFIG.VIDEO_CODECS.map(function (config) { + videoCodecs: MATROSKA_CONFIG.VIDEO_CODECS.map(function(config) { return canPlay(config, { mediaElement: mediaElement }); - }).reduce(function (result, value) { + }).reduce(function(result, value) { return result.concat(value); }, []), - audioCodecs: MATROSKA_CONFIG.AUDIO_CODEC.map(function (config) { + audioCodecs: MATROSKA_CONFIG.AUDIO_CODEC.map(function(config) { return canPlay(config, { mediaElement: mediaElement }); - }).reduce(function (result, value) { + }).reduce(function(result, value) { return result.concat(value); }, []), maxAudioChannels, diff --git a/src/withStreamingServer/withStreamingServer.js b/src/withStreamingServer/withStreamingServer.js index 516c3bd..28a0b88 100644 --- a/src/withStreamingServer/withStreamingServer.js +++ b/src/withStreamingServer/withStreamingServer.js @@ -18,10 +18,10 @@ function withStreamingServer(Video) { video.on('propValue', onVideoPropEvent.bind(null, 'propValue')); video.on('propChanged', onVideoPropEvent.bind(null, 'propChanged')); Video.manifest.events - .filter(function (eventName) { + .filter(function(eventName) { return !['error', 'propValue', 'propChanged'].includes(eventName); }) - .forEach(function (eventName) { + .forEach(function(eventName) { video.on(eventName, onOtherVideoEvent(eventName)); }); @@ -53,7 +53,7 @@ function withStreamingServer(Video) { events.emit(eventName, propName, getProp(propName, propValue)); } function onOtherVideoEvent(eventName) { - return function () { + return function() { events.emit.apply(events, [eventName].concat(Array.from(arguments))); }; } @@ -104,7 +104,7 @@ function withStreamingServer(Video) { loadArgs = commandArgs; onPropChanged('stream'); convertStream(commandArgs.streamingServerURL, commandArgs.stream, commandArgs.seriesInfo) - .then(function (result) { + .then(function(result) { var mediaURL = result.url; var infoHash = result.infoHash; var fileIdx = result.fileIdx; @@ -112,11 +112,11 @@ function withStreamingServer(Video) { mediaCapabilities: mergeWith({}, mediaCapabilities, commandArgs.mediaCapabilities) }); return (commandArgs.forceTranscoding ? Promise.resolve(false) : VideoWithStreamingServer.canPlayStream({ url: mediaURL }, canPlayStreamOptions)) - .catch(function (error) { + .catch(function(error) { console.warn('Media probe error', error); return false; }) - .then(function (canPlay) { + .then(function(canPlay) { if (canPlay) { return { mediaURL: mediaURL, @@ -134,11 +134,11 @@ function withStreamingServer(Video) { queryParams.set('forceTranscoding', '1'); } - videoCodecs.forEach(function (videoCodec) { + videoCodecs.forEach(function(videoCodec) { queryParams.append('videoCodecs', videoCodec); }); - audioCodecs.forEach(function (audioCodec) { + audioCodecs.forEach(function(audioCodec) { queryParams.append('audioCodecs', audioCodec); }); @@ -151,7 +151,7 @@ function withStreamingServer(Video) { stream: { url: url.resolve(commandArgs.streamingServerURL, '/hlsv2/' + id + '/master.m3u8?' + queryParams.toString()), subtitles: Array.isArray(commandArgs.stream.subtitles) ? - commandArgs.stream.subtitles.map(function (track) { + commandArgs.stream.subtitles.map(function(track) { return Object.assign({}, track, { url: typeof track.url === 'string' ? url.resolve(commandArgs.streamingServerURL, '/subtitles.vtt?' + new URLSearchParams([['from', track.url]]).toString()) @@ -170,7 +170,7 @@ function withStreamingServer(Video) { }; }); }) - .then(function (result) { + .then(function(result) { if (commandArgs !== loadArgs) { return; } @@ -185,7 +185,7 @@ function withStreamingServer(Video) { loaded = true; flushActionsQueue(); fetchVideoParams(commandArgs.streamingServerURL, result.mediaURL, result.infoHash, result.fileIdx, commandArgs.stream.behaviorHints) - .then(function (result) { + .then(function(result) { if (commandArgs !== loadArgs) { return; } @@ -193,7 +193,7 @@ function withStreamingServer(Video) { videoParams = result; onPropChanged('videoParams'); }) - .catch(function (error) { + .catch(function(error) { if (commandArgs !== loadArgs) { return; } @@ -204,7 +204,7 @@ function withStreamingServer(Video) { onPropChanged('videoParams'); }); }) - .catch(function (error) { + .catch(function(error) { if (commandArgs !== loadArgs) { return; } @@ -233,7 +233,7 @@ function withStreamingServer(Video) { type: 'command', commandName: 'addExtraSubtitlesTracks', commandArgs: Object.assign({}, commandArgs, { - tracks: commandArgs.tracks.map(function (track) { + tracks: commandArgs.tracks.map(function(track) { return Object.assign({}, track, { url: typeof track.url === 'string' ? url.resolve(loadArgs.streamingServerURL, '/subtitles.vtt?' + new URLSearchParams([['from', track.url]]).toString()) @@ -286,14 +286,14 @@ function withStreamingServer(Video) { } } - this.on = function (eventName, listener) { + this.on = function(eventName, listener) { if (destroyed) { throw new Error('Video is destroyed'); } events.on(eventName, listener); }; - this.dispatch = function (action) { + this.dispatch = function(action) { if (destroyed) { throw new Error('Video is destroyed'); } @@ -322,37 +322,37 @@ function withStreamingServer(Video) { }; } - VideoWithStreamingServer.canPlayStream = function (stream, options) { + VideoWithStreamingServer.canPlayStream = function(stream, options) { return Video.canPlayStream(stream) - .then(function (canPlay) { + .then(function(canPlay) { if (!canPlay) { throw new Error('Fallback using /hlsv2/probe'); } return canPlay; }) - .catch(function () { + .catch(function() { var queryParams = new URLSearchParams([['mediaURL', stream.url]]); return fetch(url.resolve(options.streamingServerURL, '/hlsv2/probe?' + queryParams.toString())) - .then(function (resp) { + .then(function(resp) { return resp.json(); }) - .then(function (probe) { + .then(function(probe) { var format = options.mediaCapabilities[probe.format.name] if (!format) { return false; } - var videoStreams = probe.streams.filter(function (stream) { + var videoStreams = probe.streams.filter(function(stream) { return stream.track === 'video'; }); - var areVideoStreamsSupported = videoStreams.length === 0 || videoStreams.some(function (stream) { + var areVideoStreamsSupported = videoStreams.length === 0 || videoStreams.some(function(stream) { return format.videoCodecs.indexOf(stream.codec) !== -1; }); - var audioStreams = probe.streams.filter(function (stream) { + var audioStreams = probe.streams.filter(function(stream) { return stream.track === 'audio'; }); - var areAudioStreamsSupported = audioStreams.length === 0 || audioStreams.some(function (stream) { + var areAudioStreamsSupported = audioStreams.length === 0 || audioStreams.some(function(stream) { return stream.channels <= format.maxAudioChannels && format.audioCodecs.indexOf(stream.codec) !== -1; }); @@ -365,11 +365,11 @@ function withStreamingServer(Video) { name: Video.manifest.name + 'WithStreamingServer', external: Video.manifest.external, props: Video.manifest.props.concat(['stream', 'videoParams']) - .filter(function (value, index, array) { return array.indexOf(value) === index; }), + .filter(function(value, index, array) { return array.indexOf(value) === index; }), commands: Video.manifest.commands.concat(['load', 'unload', 'destroy', 'addExtraSubtitlesTracks']) - .filter(function (value, index, array) { return array.indexOf(value) === index; }), + .filter(function(value, index, array) { return array.indexOf(value) === index; }), events: Video.manifest.events.concat(['propValue', 'propChanged', 'error']) - .filter(function (value, index, array) { return array.indexOf(value) === index; }) + .filter(function(value, index, array) { return array.indexOf(value) === index; }) }; return VideoWithStreamingServer;