Error message

User warning: The following module is missing from the file system: fast_404. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1143 of /mnt/www/html/ooyala/docroot/includes/

Escuchar un evento del bus de mensajes

Puede utilizar el bus de mensajes para escuchar un único evento o varios eventos.

El siguiente ejemplo ilustra cómo utilizar el bus de mensajes para escuchar un evento y cómo utilizar addDependent para bloquear un evento de pausa y mostrar un mensaje de confirmación.

Ejemplo: escuchar un evento

El siguiente ejemplo muestra cómo utilizar el bus de mensajes para escuchar un evento.

<!DOCTYPE html>


 <!-- Load Ooyala Player -->
 <script src=''>


 <!-- Player Placement -->
 <div id='playerwrapper' style='width:480px;height:360px;'></div>

     var videoPlayer = OO.Player.create('playerwrapper','
     video_embed_code', {
       onCreate: function(player) {
         window.messageBus = player.mb;  // save reference to message bus

     // listen for playing event
     // it's possible to listen to any event defined in OO.EVENTS or '*' 
     to get all events
     window.messageBus.subscribe(OO.EVENTS.PLAYING, 'example', 
     function(eventName) {
       alert("Player is now playing!!!");

     // send play
     // it's also possible to send any event to change player’s behavior
     // of course some events require specific parameters to be understood properly
     // or maybe be possible to execute only at specific times
        window.messageBus.publish(OO.EVENTS.PLAY);  // starts playback, 
        you can also use as shortcut

     // for a more advanced use case of blocking events on other events:
     // let's say we want to block 'pause' function so that
     // when 'pause' is pressed,
     // we can display message box asking for confirmation
     // to do that, we can use addDependent() function
        window.messageBus.addDependent(OO.EVENTS.PAUSE, 'user_allowed_pause', 
        'example', function(eventName) {
       // when 'pause' event occurs - i.e. user pressed on pause button in
          ui (or videoPlayer.pause() was called)
       // this code will execute

       // ask user for confirmation
         onOk: function() {
                 // after this event is sent, pause is unblocked,
                // and player will pause