cycjimmy / jsmpeg-player

MPEG1 Video Player Based On JSMpeg.

Home Page:https://www.npmjs.com/package/@cycjimmy/jsmpeg-player

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

implement callbacks ?

kresimirfijacko opened this issue · comments

Hi,
when are you going to support callbacks such as:
onSourceEstablished, onSourceCompleted
?

There are two ways to call callback methods:

  1. Set hooks options:
new JSMpeg.VideoElement(videoWrapper, videoUrl , {
  hooks: {
    play: () => console.log('onPlay'),
    pause: () => console.log('onPause'),
    stop: () => console.log('onStop'),
    load: () => console.log('onSourceEstablished or onSourceCompleted')
  },
  ...otherOptions
});
  1. Use callbacks of the original jsmpeg such as onSourceEstablished, onSourceCompleted to override the settings. (Set the fourth parameter)
new JSMpeg.VideoElement(videoWrapper, videoUrl, options , {
  onSourceEstablished: (source) => console.log('onSourceEstablished'),
  onSourceCompleted: (source) => console.log('onSourceCompleted'),
  ...otherOptions
});