Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: iframe transport #85

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"browser": true
},
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 8
},
"ignorePatterns": [
"/*",
Expand Down Expand Up @@ -56,6 +56,7 @@
"allowEmptyCatch": true
}
],
"no-inner-declarations": "off",
"no-prototype-builtins": "off",
"no-template-curly-in-string": "error",
"no-trailing-spaces": "error",
Expand All @@ -67,7 +68,6 @@
"varsIgnorePattern": "_"
}
],
"prefer-const": "error",
"quotes": [
"error",
"single"
Expand Down
12 changes: 6 additions & 6 deletions src/StremioVideo/selectVideoImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ function selectVideoImplementation(commandArgs, options) {
}

if (typeof commandArgs.streamingServerURL === 'string') {
if (typeof global.tizen !== 'undefined') {
if (commandArgs.platform === 'Tizen') {
return withStreamingServer(withHTMLSubtitles(TizenVideo));
}
if (typeof global.webOS !== 'undefined') {
if (commandArgs.platform === 'webOS') {
return withStreamingServer(withHTMLSubtitles(WebOsVideo));
}
return withStreamingServer(withHTMLSubtitles(HTMLVideo));
}

if (typeof commandArgs.stream.url === 'string') {
if (typeof global.webOS !== 'undefined') {
return withVideoParams(withHTMLSubtitles(WebOsVideo));
}
if (typeof global.tizen !== 'undefined') {
if (commandArgs.platform === 'Tizen') {
return withVideoParams(withHTMLSubtitles(TizenVideo));
}
if (commandArgs.platform === 'webOS') {
return withVideoParams(withHTMLSubtitles(WebOsVideo));
}
return withVideoParams(withHTMLSubtitles(HTMLVideo));
}

Expand Down
98 changes: 98 additions & 0 deletions src/TizenVideo/AVPlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const SCOPE = 'AVPlay';

const createAVPlay = (transport) => {
const getState = () => {
return transport.request(SCOPE, 'getState');
};

const getCurrentTime = () => {
return transport.request(SCOPE, 'getCurrentTime');
};

const getDuration = () => {
return transport.request(SCOPE, 'getDuration');
};

const getTotalTrackInfo = () => {
return transport.request(SCOPE, 'getTotalTrackInfo');
};

const getCurrentStreamInfo = () => {
return transport.request(SCOPE, 'getCurrentStreamInfo');
};

const open = (path) => {
return transport.request(SCOPE, 'open', path);
};

const prepareAsync = async (successHandler, errorHandler) => {
const [handler, handlerResult] = await transport.request(SCOPE, 'prepareAsync', 'handler:success', 'handler:error');
if (handler === 'handler:success') successHandler();
if (handler === 'handler:error') errorHandler(...handlerResult);
};

const pause = () => {
return transport.request(SCOPE, 'pause');
};

const play = () => {
return transport.request(SCOPE, 'play');
};

const stop = () => {
return transport.request(SCOPE, 'stop');
};

const seekTo = (time) => {
return transport.request(SCOPE, 'seekTo', time);
};

const setSpeed = (rate) => {
return transport.request(SCOPE, 'setSpeed', rate);
};

const setSelectTrack = (type, id) => {
return transport.request(SCOPE, 'setSelectTrack', type, id);
};

const setDisplayRect = (x, y, width, height) => {
return transport.request(SCOPE, 'setDisplayRect', x, y, width, height);
};

const setDisplayMethod = (method) => {
return transport.request(SCOPE, 'setDisplayMethod', method);
};

const setListener = (listener) => {
const handlers = Object.keys(listener).map((name) => `handler:${name}`);
const onHandlerResponse = (handler, handlerResult) => {
const name = handler.replace('handler:', '');
if (listener[name]) {
handlerResult ? listener[name](...handlerResult) : listener[name]();
}
};

transport.listen(SCOPE, 'setListener', onHandlerResponse, ...handlers);
};

return {
getState,
getCurrentTime,
getDuration,
getTotalTrackInfo,
getCurrentStreamInfo,
open,
prepareAsync,
pause,
play,
stop,
seekTo,
setSpeed,
setSelectTrack,
setDisplayRect,
setDisplayMethod,
setListener,
};
};

module.exports = createAVPlay;
Loading
Loading