Question

I can't find any examples where I can insert a video player code into the tinymce 4.x, I'have a jwplayer downloaded, but I don't know how to insert the javascript code into the editor to execute this for each added video:

jwplayer(id).setup({
                    file: video.href,
                    image: video.img,
                    title: video.title,
                    width: '640',
                    height: '360',
                    primary: 'flash',
                    aspectratio: '16:9'
                });

please any help!

Was it helpful?

Solution

You should try initialising the player in the onLoadContent event handler of TinyMCE.

E.g.

tinyMCE.init({
   ...
   setup : function(ed) {
      ed.onLoadContent.add(function(ed, o) {
         jwplayer(id).setup({
            file: video.href,
            image: video.img,
            title: video.title,
            width: '640',
            height: '360',
            primary: 'flash',
            aspectratio: '16:9'
          });
      });
   }
});

The pont is that you need an element in user provided content to be available for DOM manipulation before setting up the player.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top