a-ignatov-parc/tvdml

Video player close event

john-trovalto opened this issue · 3 comments

Is there any way in which I can detect that the player has been closed? I'm creating a player object on button select event and the video starts without any issues.

If I'm pressing the menu button, the player gets close but I'm not getting the event on menu button select event. I'm registering the menu select event in the component which extends react pure component and has a button which starts the video on click/select.

I checked the official documentation but couldn't find any which can help me with this.

Unfortunately, menu-button-press can only detect navigation between documents (screens) and player is always displayed as an overlay on the same screen.

However, we can detect when the player is dismissed with its own events.

const player = new Player();

player.playlist = new Playlist();
player.playlist.push(mediaItem);

player.addEventListener('stateDidChange', event => {
    if (event.state === 'end') {
        handlePlayerClosure();
    }
});

player.play();

More info about available events can be found in the TVJS documentation

Okay, thank you for the detailed answer. I have already integrated state change listener but it never got called when I closed the player with a menu button. I guess I have to do add some logic in the document from which the player gets opened.

You're welcome. I'll close the issue, but feel free to ask questions if you have other problems 👍