MaxvandeLaar / homey-webos-plus

Improved LG WebOS integration for Homey
GNU General Public License v3.0
27 stars 11 forks source link

Enable current app media screen #8

Closed kaohlive closed 4 years ago

kaohlive commented 4 years ago

In Homey devices when you open your LG WebOS TV you get the controls to do some light interaction with the tv. What I would like is to see what App/Input is active on the TV as the AlbumArt inlcuding media controls. So I can see that the Netflix app is running with its logo and allowing for the prev play/pause next buttons to interact with it.

Similar behavior can be seen by the official LG tv app or the Xbox one compagnion app as examples.

Code needed for this looks like: On device init: this.appImage = new Homey.Image(); this.appImage.setPath('/assets/images/hdmi.jpg')); this.appImage.register().catch(console.error).then(function(){this.setAlbumArtImage(this.appImage);}.bind(this)); This loads the the hdmi image as the default. later on somewhere in your new app detection code: //Getting the app image from an external source, device api/internet for example this.appImage.setStream(async (stream) => { const res = await fetch(appInfo.displayImage); //object with the URL to the image for example if(!res.ok) throw new Error('Invalid Response'); return res.body.pipe(stream); }); this.appImage.update();

The media controls are standard capabilities you can enable: if(!this.hasCapability("speaker_playing")) await this.addCapability('speaker_playing'); if(!this.hasCapability("speaker_next")) await this.addCapability("speaker_next"); if(!this.hasCapability("speaker_prev")) await this.addCapability("speaker_prev");

MaxvandeLaar commented 4 years ago

Sounds interesting, I'll definitely see what I can do.

kaohlive commented 4 years ago

Very strange but I still do not get a pause/play button. I have the Netflix logo, I have the prev/next buttons, but no play/pause.

I added the following code to the device before install: if(!this.hasCapability("speaker_playing")) { await this.addCapability("speaker_playing"); }

And now i do have the button. So it probably only works for newly added devices.

MaxvandeLaar commented 4 years ago

Hmm interesting, my devices are added since version 0.1.0 and haven't been readded. But I do see that I have every other speaker_* capability added except speaker_playing so that might be the problem indeed. Maybe my home persists this capability somewhere and I suppose it will disappear when I reboot it. Glad that you fixed it for yourself, I'll add it to the list.