Skip to content

Commit

Permalink
feat: iframe transport for tizen
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Aug 6, 2024
1 parent 3246ebf commit ab3902f
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 51 deletions.
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, result] = await transport.request(SCOPE, 'prepareAsync', 'handler:success', 'handler:error');
if (handler === 'handler:success') successHandler();
if (handler === 'handler:error') errorHandler(...result);
};

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, result) => {
const name = handler.replace('handler:', '');
if (listener[name]) {
result ? listener[name](...result) : 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

0 comments on commit ab3902f

Please sign in to comment.