Created
May 27, 2024 08:05
-
-
Save aabytt/8d964241d08a5fd10e5f0fdeede94a54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function webosScreensaverLaunch() { | |
| webOS.service.request('luna://org.webosbrew.hbchannel.service', { | |
| method: 'exec', | |
| parameters: { | |
| command: 'luna-send -n 1 luna://com.webos.service.tvpower/power/turnOnScreenSaver {}' | |
| }, | |
| onSuccess: function(event) { | |
| console.log('Screensaver', 'webOS screenSaver [Success]', JSON.stringify(event)); | |
| }, | |
| onFailure: function(event) { | |
| console.log('Screensaver', 'webOS screenSaver [Failed][', event.errorCode + ' ]', event.errorText); | |
| }, | |
| }); | |
| } | |
| var pausedPosition = 0; | |
| Lampa.Screensaver.listener.follow('start', function() { | |
| console.log('Screensaver', 'started'); | |
| if (document.getElementsByTagName('video')[0]) { | |
| pausedPosition = document.getElementsByTagName('video')[0].currentTime; | |
| console.log('Paused timecode:', pausedPosition); | |
| } | |
| webosScreensaverLaunch(); | |
| }) | |
| Lampa.Screensaver.listener.follow('stop', function() { | |
| console.log('Screensaver', 'stopped'); | |
| if (document.getElementsByTagName('video')[0]) { | |
| document.getElementsByTagName('video')[0].load(); | |
| console.log('Paused timecode:', pausedPosition); | |
| const videoReloaded = document.querySelector("video"); | |
| videoReloaded.addEventListener("loadeddata", (event) => { | |
| console.log("Screensaver: Listening for loadeddata"); | |
| }); | |
| videoReloaded.onloadeddata = (event) => { | |
| console.log("Screensaver: seeking to saved position"); | |
| document.getElementsByTagName('video')[0].currentTime = pausedPosition; | |
| }; | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment