mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Fixed additional webOS 6.0/5.0 playback issues
This commit is contained in:
parent
5c071fb202
commit
593bb69d49
4 changed files with 21 additions and 29 deletions
|
@ -45,7 +45,6 @@ export class Main {
|
||||||
keepAlive = activity;
|
keepAlive = activity;
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Fix issue of emitting events to non-existent subscribers after multiple page changes
|
|
||||||
const voidCb = (message: any) => { message.respond({ returnValue: true, value: {} }); };
|
const voidCb = (message: any) => { message.respond({ returnValue: true, value: {} }); };
|
||||||
const objectCb = (message: any, value: any) => { message.respond({ returnValue: true, value: value }); };
|
const objectCb = (message: any, value: any) => { message.respond({ returnValue: true, value: value }); };
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ export class Main {
|
||||||
},
|
},
|
||||||
(message: any) => {
|
(message: any) => {
|
||||||
Main.logger.info('Canceled play service subscriber');
|
Main.logger.info('Canceled play service subscriber');
|
||||||
Main.emitter.off('play', playClosureCb);
|
Main.emitter.removeAllListeners('play');
|
||||||
message.respond({ returnValue: true, value: message.payload });
|
message.respond({ returnValue: true, value: message.payload });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -114,7 +113,7 @@ export class Main {
|
||||||
},
|
},
|
||||||
(message: any) => {
|
(message: any) => {
|
||||||
Main.logger.info('Canceled stop service subscriber');
|
Main.logger.info('Canceled stop service subscriber');
|
||||||
Main.emitter.off('stop', stopClosureCb);
|
Main.emitter.removeAllListeners('stop');
|
||||||
message.respond({ returnValue: true, value: message.payload });
|
message.respond({ returnValue: true, value: message.payload });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -208,7 +207,7 @@ function registerService(service: Service, method: string, callback: (message: a
|
||||||
},
|
},
|
||||||
(message: any) => {
|
(message: any) => {
|
||||||
Main.logger.info(`Canceled ${method} service subscriber`);
|
Main.logger.info(`Canceled ${method} service subscriber`);
|
||||||
Main.emitter.off(method, callbackRef);
|
Main.emitter.removeAllListeners(method);
|
||||||
message.respond({ returnValue: true, value: message.payload });
|
message.respond({ returnValue: true, value: message.payload });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ try {
|
||||||
const playService = registerService('play', (message: any) => {
|
const playService = registerService('play', (message: any) => {
|
||||||
if (message.value !== undefined && message.value.playData !== undefined) {
|
if (message.value !== undefined && message.value.playData !== undefined) {
|
||||||
console.log(`Main: Playing ${JSON.stringify(message)}`);
|
console.log(`Main: Playing ${JSON.stringify(message)}`);
|
||||||
|
sessionStorage.setItem('playData', JSON.stringify(message.value.playData));
|
||||||
getDeviceInfoService.cancel();
|
getDeviceInfoService.cancel();
|
||||||
toastService.cancel();
|
toastService.cancel();
|
||||||
onConnectService.cancel();
|
onConnectService.cancel();
|
||||||
|
@ -37,18 +38,18 @@ try {
|
||||||
// WebOS 22 and earlier does not work well using the history API,
|
// WebOS 22 and earlier does not work well using the history API,
|
||||||
// so manually handling page navigation...
|
// so manually handling page navigation...
|
||||||
// history.pushState({}, '', '../main_window/index.html');
|
// history.pushState({}, '', '../main_window/index.html');
|
||||||
window.open('../player/index.html');
|
window.open('../player/index.html', '_self');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const launchHandler = (args: any) => {
|
const launchHandler = () => {
|
||||||
// args don't seem to be passed in via event despite what documentation says...
|
|
||||||
const params = window.webOSDev.launchParams();
|
const params = window.webOSDev.launchParams();
|
||||||
console.log(`Main: (Re)launching FCast Receiver with args: ${JSON.stringify(params)}`);
|
console.log(`Main: (Re)launching FCast Receiver with args: ${JSON.stringify(params)}`);
|
||||||
|
|
||||||
const lastTimestamp = localStorage.getItem('lastTimestamp');
|
const lastTimestamp = Number(localStorage.getItem('lastTimestamp'));
|
||||||
if (params.playData !== undefined && params.timestamp != lastTimestamp) {
|
if (params.playData !== undefined && params.timestamp != lastTimestamp) {
|
||||||
localStorage.setItem('lastTimestamp', params.timestamp);
|
localStorage.setItem('lastTimestamp', params.timestamp);
|
||||||
|
sessionStorage.setItem('playData', JSON.stringify(params.playData));
|
||||||
toastService?.cancel();
|
toastService?.cancel();
|
||||||
getDeviceInfoService?.cancel();
|
getDeviceInfoService?.cancel();
|
||||||
onConnectService?.cancel();
|
onConnectService?.cancel();
|
||||||
|
@ -59,12 +60,12 @@ try {
|
||||||
// WebOS 22 and earlier does not work well using the history API,
|
// WebOS 22 and earlier does not work well using the history API,
|
||||||
// so manually handling page navigation...
|
// so manually handling page navigation...
|
||||||
// history.pushState({}, '', '../main_window/index.html');
|
// history.pushState({}, '', '../main_window/index.html');
|
||||||
window.open('../player/index.html');
|
window.open('../player/index.html', '_self');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('webOSLaunch', (ags) => { launchHandler(ags)});
|
document.addEventListener('webOSLaunch', launchHandler);
|
||||||
document.addEventListener('webOSRelaunch', (ags) => { launchHandler(ags)});
|
document.addEventListener('webOSRelaunch', launchHandler);
|
||||||
|
|
||||||
// Cannot go back to a state where user was previously casting a video, so exit.
|
// Cannot go back to a state where user was previously casting a video, so exit.
|
||||||
// window.onpopstate = () => {
|
// window.onpopstate = () => {
|
||||||
|
|
|
@ -8,10 +8,8 @@ require('lib/webOSTVjs-1.2.10/webOSTV-dev.js');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const serviceId = 'com.futo.fcast.receiver.service';
|
const serviceId = 'com.futo.fcast.receiver.service';
|
||||||
let playerWindowOpen = false;
|
|
||||||
|
|
||||||
window.webOSAPI = {
|
window.webOSAPI = {
|
||||||
pendingPlay: null
|
pendingPlay: JSON.parse(sessionStorage.getItem('playData'))
|
||||||
};
|
};
|
||||||
|
|
||||||
preloadData.sendPlaybackErrorCb = (error: PlaybackErrorMessage) => {
|
preloadData.sendPlaybackErrorCb = (error: PlaybackErrorMessage) => {
|
||||||
|
@ -58,10 +56,6 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.value.playData !== null) {
|
if (message.value.playData !== null) {
|
||||||
if (!playerWindowOpen) {
|
|
||||||
playerWindowOpen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preloadData.onPlayCb === undefined) {
|
if (preloadData.onPlayCb === undefined) {
|
||||||
window.webOSAPI.pendingPlay = message.value.playData;
|
window.webOSAPI.pendingPlay = message.value.playData;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +74,6 @@ try {
|
||||||
const pauseService = registerService('pause', () => { preloadData.onPauseCb(); });
|
const pauseService = registerService('pause', () => { preloadData.onPauseCb(); });
|
||||||
const resumeService = registerService('resume', () => { preloadData.onResumeCb(); });
|
const resumeService = registerService('resume', () => { preloadData.onResumeCb(); });
|
||||||
const stopService = registerService('stop', () => {
|
const stopService = registerService('stop', () => {
|
||||||
playerWindowOpen = false;
|
|
||||||
playService.cancel();
|
playService.cancel();
|
||||||
pauseService.cancel();
|
pauseService.cancel();
|
||||||
resumeService.cancel();
|
resumeService.cancel();
|
||||||
|
@ -92,23 +85,22 @@ try {
|
||||||
// WebOS 22 and earlier does not work well using the history API,
|
// WebOS 22 and earlier does not work well using the history API,
|
||||||
// so manually handling page navigation...
|
// so manually handling page navigation...
|
||||||
// history.back();
|
// history.back();
|
||||||
window.open('../main_window/index.html');
|
window.open('../main_window/index.html', '_self');
|
||||||
});
|
});
|
||||||
|
|
||||||
const seekService = registerService('seek', (message: any) => { preloadData.onSeekCb(null, message.value); });
|
const seekService = registerService('seek', (message: any) => { preloadData.onSeekCb(null, message.value); });
|
||||||
const setVolumeService = registerService('setvolume', (message: any) => { preloadData.onSetVolumeCb(null, message.value); });
|
const setVolumeService = registerService('setvolume', (message: any) => { preloadData.onSetVolumeCb(null, message.value); });
|
||||||
const setSpeedService = registerService('setspeed', (message: any) => { preloadData.onSetSpeedCb(null, message.value); });
|
const setSpeedService = registerService('setspeed', (message: any) => { preloadData.onSetSpeedCb(null, message.value); });
|
||||||
|
|
||||||
const launchHandler = (args: any) => {
|
const launchHandler = () => {
|
||||||
// args don't seem to be passed in via event despite what documentation says...
|
// args don't seem to be passed in via event despite what documentation says...
|
||||||
const params = window.webOSDev.launchParams();
|
const params = window.webOSDev.launchParams();
|
||||||
console.log(`Player: (Re)launching FCast Receiver with args: ${JSON.stringify(params)}`);
|
console.log(`Player: (Re)launching FCast Receiver with args: ${JSON.stringify(params)}`);
|
||||||
|
|
||||||
const lastTimestamp = localStorage.getItem('lastTimestamp');
|
const lastTimestamp = Number(localStorage.getItem('lastTimestamp'));
|
||||||
if (params.playData !== undefined && params.timestamp != lastTimestamp) {
|
if (params.playData !== undefined && params.timestamp != lastTimestamp) {
|
||||||
localStorage.setItem('lastTimestamp', params.timestamp);
|
localStorage.setItem('lastTimestamp', params.timestamp);
|
||||||
playerWindowOpen = false;
|
sessionStorage.setItem('playData', JSON.stringify(params.playData));
|
||||||
|
|
||||||
playService?.cancel();
|
playService?.cancel();
|
||||||
pauseService?.cancel();
|
pauseService?.cancel();
|
||||||
resumeService?.cancel();
|
resumeService?.cancel();
|
||||||
|
@ -120,12 +112,12 @@ try {
|
||||||
// WebOS 22 and earlier does not work well using the history API,
|
// WebOS 22 and earlier does not work well using the history API,
|
||||||
// so manually handling page navigation...
|
// so manually handling page navigation...
|
||||||
// history.pushState({}, '', '../main_window/index.html');
|
// history.pushState({}, '', '../main_window/index.html');
|
||||||
window.open('../player/index.html');
|
window.open('../player/index.html', '_self');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('webOSLaunch', (ags) => { launchHandler(ags)});
|
document.addEventListener('webOSLaunch', launchHandler);
|
||||||
document.addEventListener('webOSRelaunch', (ags) => { launchHandler(ags)});
|
document.addEventListener('webOSRelaunch', launchHandler);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
|
@ -91,7 +91,7 @@ export function targetKeyDownEventListener(event: any): boolean {
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case RemoteKeyCode.Stop:
|
case RemoteKeyCode.Stop:
|
||||||
// history.back();
|
// history.back();
|
||||||
window.open('../main_window/index.html');
|
window.open('../main_window/index.html', '_self');
|
||||||
handledCase = true;
|
handledCase = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ export function targetKeyDownEventListener(event: any): boolean {
|
||||||
// so manually handling page navigation...
|
// so manually handling page navigation...
|
||||||
case RemoteKeyCode.Back:
|
case RemoteKeyCode.Back:
|
||||||
// history.back();
|
// history.back();
|
||||||
window.open('../main_window/index.html');
|
window.open('../main_window/index.html', '_self');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
handledCase = true;
|
handledCase = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue