fe02f9d6 by David LaPalomento

Autoplay if requested

Call play as soon as the media source has been set if autoplay is present in the player options.
1 parent bd468d14
...@@ -584,6 +584,10 @@ var ...@@ -584,6 +584,10 @@ var
584 src: videojs.URL.createObjectURL(mediaSource), 584 src: videojs.URL.createObjectURL(mediaSource),
585 type: "video/flv" 585 type: "video/flv"
586 }]); 586 }]);
587
588 if (player.options().autoplay) {
589 player.play();
590 }
587 }; 591 };
588 592
589 videojs.plugin('hls', function() { 593 videojs.plugin('hls', function() {
......
...@@ -55,7 +55,7 @@ var ...@@ -55,7 +55,7 @@ var
55 module('HLS', { 55 module('HLS', {
56 setup: function() { 56 setup: function() {
57 57
58 // mock out Flash feature for phantomjs 58 // mock out Flash features for phantomjs
59 oldFlashSupported = videojs.Flash.isSupported; 59 oldFlashSupported = videojs.Flash.isSupported;
60 videojs.Flash.isSupported = function() { 60 videojs.Flash.isSupported = function() {
61 return true; 61 return true;
...@@ -118,6 +118,20 @@ module('HLS', { ...@@ -118,6 +118,20 @@ module('HLS', {
118 } 118 }
119 }); 119 });
120 120
121 test('starts playing if autoplay is specified', function() {
122 var plays = 0;
123 player.play = function() {
124 plays++;
125 };
126 player.options().autoplay = true;
127 player.hls('manifest/playlist.m3u8');
128 videojs.mediaSources[player.currentSrc()].trigger({
129 type: 'sourceopen'
130 });
131
132 strictEqual(1, plays, 'play was called');
133 });
134
121 test('loads the specified manifest URL on init', function() { 135 test('loads the specified manifest URL on init', function() {
122 var loadedmanifest = false, loadedmetadata = false; 136 var loadedmanifest = false, loadedmetadata = false;
123 player.on('loadedmanifest', function() { 137 player.on('loadedmanifest', function() {
......