From 8d3ead286699e95442ac80712aa4f164d6f3c26b Mon Sep 17 00:00:00 2001 From: Frank Ronny Larsen Date: Wed, 20 Feb 2013 13:40:54 +0100 Subject: [PATCH] BUGFIX: Show video in IE9 too. --- js/h5p.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index a68de56..8f01338 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -81,16 +81,30 @@ H5P.playVideo = function ($target, params, cp, onEnded) { var sources = ''; var willWork = false; // Used for testing if video tag is supported, AND for testing if we can play back our given formats - var $video = $(''); - if ($video[0].canPlayType !== undefined) { + var video = document.createElement('video'); + video.autoplay = true; + video.width = width; + video.height = height; + + if (video.canPlayType !== undefined) { for (var key in params) { - sources += ''; - willWork = willWork || $video[0].canPlayType(key); + // TODO: The files should probably be in their own group. + if (key.indexOf('video') === 0) { + if (video.canPlayType(key)) { + var source = document.createElement('source'); + source.src = cp + params[key]; + source.type = key; + video.appendChild(source); + willWork = willWork || true; + } + } } - $video.html(sources); if (willWork) { - $container.append($video); + $container.append(video); + $(video).on('ended', function() { + onEnded(); + }); } } @@ -98,9 +112,13 @@ H5P.playVideo = function ($target, params, cp, onEnded) { if (!willWork) { // use flowplayer fallback var fp_container = document.createElement("div"); + fp_container.width = "100%"; + fp_container.height = "100%"; fplayer = flowplayer(fp_container, { src: "http://releases.flowplayer.org/swf/flowplayer-3.2.16.swf", - wmode: "opaque" + wmode: "opaque", + width: width, + height: height }, { buffering: true, clip: {