Picture of Jack Ward
Extended media contrib plugin to add custom event
by Jack Ward - Thursday, 8 September 2016, 3:31 PM
 

Hi,I'm looking to bind a completion event when a video finishes playing that will reveal the original poster image. I'm wondering whether I can expand the existing component to do this via our theme.

My knowledge of Backbone isn't massive but having thoroughly Google'd and searched through the docs I'm stumped on how I'd do this and would ideally like to avoid creating a new component to complete this simple change.

So far I have the below as a script included into the theme.js

define(function(require) {
    
    // var Adapt = require('coreJS/adapt');
    var Media = require('components/adapt-contrib-media/js/adapt-contrib-media');

    Media = Media.extend({
        initialize: function(){

            var modelOptions = this.model.get('_playerOptions');
            modelOptions.success = _.bind(this.createPosterEvent, this);
        },
        createPosterEvent: function(){
            //Poster will appear
        }
    });
     return Media;
});

Appreciate any help that can be offered.

Thanks guys.

Picture of Matt Leathes
Re: Extended media contrib plugin to add custom event
by Matt Leathes - Thursday, 8 September 2016, 5:17 PM
 

might be easier just to add the following into the .json for that component:

"_playerOptions" : {
    "showPosterWhenEnded": true
}
Picture of Jack Ward
Re: Extended media contrib plugin to add custom event
by Jack Ward - Friday, 9 September 2016, 8:12 AM
 

Probably should have been more specific. We're using the authoring tool.

I've always had trouble entering player options via the authoring tool. What would I enter into the text-box. I've tried:

"showPosterWhenEnded":true

{ "showPosterWhenEnded":true}

Picture of Jack Ward
Re: Extended media contrib plugin to add custom event
by Jack Ward - Friday, 9 September 2016, 8:27 AM
 

Just noticed that the authoring tool is adding quotes around the player options preventing it from creating the object.

If I enter {"showPosterWhenEnded": true} into the player options field, "{"showPosterWhenEnded": true}" is what is seen in my ff debug window.

Picture of Matt Leathes
Re: Extended media contrib plugin to add custom event
by Matt Leathes - Friday, 9 September 2016, 9:02 AM
 

Ah yes, sorry - this is a known issue which is in the process of being fixed.

If you wanted to press ahead and do it anyway you just need to amend the contrib-media code to add that setting in, still far easier than attempting to implement the 'show poster at end' functionality yourself

Picture of Jack Ward
Re: Extended media contrib plugin to add custom event
by Jack Ward - Friday, 9 September 2016, 9:50 AM
 

Cheers mate. I'll leave it at that for now.

Was genuinely curious how that could be done through backbone but think i've exhausted any possible ways.