Skip to content

Commit

Permalink
revert formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
unclekingpin committed Nov 2, 2023
1 parent db83bef commit ef6e22b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions src/mediaCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
56 changes: 28 additions & 28 deletions src/withStreamingServer/withStreamingServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

Expand Down Expand Up @@ -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)));
};
}
Expand Down Expand Up @@ -104,19 +104,19 @@ 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;
var canPlayStreamOptions = Object.assign({}, commandArgs, {
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,
Expand All @@ -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);
});

Expand All @@ -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())
Expand All @@ -170,7 +170,7 @@ function withStreamingServer(Video) {
};
});
})
.then(function (result) {
.then(function(result) {
if (commandArgs !== loadArgs) {
return;
}
Expand All @@ -185,15 +185,15 @@ 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;
}

videoParams = result;
onPropChanged('videoParams');
})
.catch(function (error) {
.catch(function(error) {
if (commandArgs !== loadArgs) {
return;
}
Expand All @@ -204,7 +204,7 @@ function withStreamingServer(Video) {
onPropChanged('videoParams');
});
})
.catch(function (error) {
.catch(function(error) {
if (commandArgs !== loadArgs) {
return;
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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;
});
Expand All @@ -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;
Expand Down

0 comments on commit ef6e22b

Please sign in to comment.