Skip to content

Commit cc2bd10

Browse files
committed
Merge pull request Dash-Industry-Forum#55 from senthil-codr/autoplay_fix
Autoplay bug fix
2 parents 5553987 + 32cc67d commit cc2bd10

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

app/js/streaming/MediaPlayer.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ MediaPlayer = function (aContext) {
7575
this.debug.log("Playback initiated!");
7676
streamController = system.getObject("streamController");
7777
streamController.setVideoModel(this.videoModel);
78+
streamController.setAutoPlay(autoPlay);
7879
streamController.load(source);
7980
},
8081

8182
doAutoPlay = function () {
82-
if (autoPlay && isReady()) {
83+
if (isReady()) {
8384
play.call(this);
8485
}
8586
};
@@ -179,10 +180,6 @@ MediaPlayer = function (aContext) {
179180

180181
element = view;
181182

182-
// Set the video to autoplay.
183-
// We'll tell it when to go.
184-
element.autoplay = true;
185-
186183
model = new MediaPlayer.models.VideoModel(element);
187184
this.videoModel.setElement(element);
188185

app/js/streaming/Stream.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,6 @@ MediaPlayer.dependencies.Stream = function () {
581581
self.debug.log("Start initializing playback.");
582582
return initializePlayback.call(self);
583583
}
584-
).then(
585-
function (/*done*/) {
586-
self.debug.log("Playback initialized!");
587-
play.call(self);
588-
return load.promise;
589-
}
590584
).then(
591585
function () {
592586
self.debug.log("element loaded!");
@@ -598,6 +592,10 @@ MediaPlayer.dependencies.Stream = function () {
598592
}
599593
initPlayback.call(self);
600594

595+
if (autoPlay) {
596+
self.debug.log("Playback initialized!");
597+
play.call(self);
598+
}
601599
}
602600
);
603601
},
@@ -802,4 +800,4 @@ MediaPlayer.dependencies.Stream = function () {
802800

803801
MediaPlayer.dependencies.Stream.prototype = {
804802
constructor: MediaPlayer.dependencies.Stream
805-
};
803+
};

app/js/streaming/StreamController.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
//TODO set correct value for threshold
2525
STREAM_BUFFER_END_THRESHOLD = 4,
2626
STREAM_END_THRESHOLD = 3,
27+
autoPlay = true,
2728
deferredSwitch= null,
2829

2930
play = function () {
@@ -230,11 +231,11 @@
230231
},
231232

232233
setAutoPlay: function (value) {
233-
activeStream.setAutoPlay(value);
234+
autoPlay = value;
234235
},
235236

236237
getAutoPlay: function () {
237-
return activeStream.getAutoPlay();
238+
return autoPlay;
238239
},
239240

240241
getVideoModel: function () {
@@ -258,6 +259,7 @@
258259
stream = self.system.getObject("stream");
259260
stream.setVideoModel(i === 0 ? self.videoModel : createVideoModel.call(self));
260261
stream.initProtection();
262+
stream.setAutoPlay(autoPlay);
261263
stream.load(manifest, i);
262264
streams.push(stream);
263265
}

app/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ $(document).ready(function() {
11081108
player.addEventListener("log", onLogMessage.bind(this));
11091109
player.addEventListener("error", onError.bind(this));
11101110

1111-
player.autoPlay = true;
1111+
player.setAutoPlay(true);
11121112
player.attachView(video);
11131113

11141114
if (specifiedMpd !== null) {

baseline.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
player.attachSource(url);
3636

3737
video = document.querySelector(".dash-video-player video"),
38-
player.autoPlay = true;
38+
player.setAutoPlay(true);
3939
player.attachView(video);
4040
}
4141
</script>

0 commit comments

Comments
 (0)