window.benecasterFrontend.getPlayer()
window.benecasterFrontend.getPlayer( episodeId: number | null ): HTMLMediaElement | null
A JavaScript function, not a PHP one. Returns the media element of an episode’s player on the page, so you can read currentTime, duration or paused directly, or attach your own listeners. It finds players by the same rules as window.benecasterFrontend.seek(), and null means the same: that episode has no player here.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
episodeId |
number|null |
— | Yes | The episode whose player to find, or null for the first Benecaster player on the page. |
Return Value
Type:
HTMLMediaElement|null
The ` or element seek() would use for that episode, or null` when there is none on the page.
Example
const media = window.benecasterFrontend?.getPlayer( 42 );
if ( media ) {
media.addEventListener( 'ended', () => showNextEpisodePrompt() );
}
Notes
Same dependency as seek(): the benecaster-frontend script must be on the page. For following playback, the benecaster:timeupdate event described on the seek() page is usually simpler than your own timeupdate listener.
Need this built rather than just documented? See our services →