Skip to content

Commit 85cc335

Browse files
author
Nathan Weber
committed
Merge branch 'development' of https://github.com/Dash-Industry-Forum/dash.js into development
Conflicts: app/main.js
2 parents 9f4a070 + cc2bd10 commit 85cc335

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
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
};
@@ -166,10 +167,6 @@ MediaPlayer = function (aContext) {
166167

167168
element = view;
168169

169-
// Set the video to autoplay.
170-
// We'll tell it when to go.
171-
element.autoplay = true;
172-
173170
model = new MediaPlayer.models.VideoModel(element);
174171
this.videoModel.setElement(element);
175172

app/js/streaming/Stream.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,6 @@ MediaPlayer.dependencies.Stream = function () {
582582
self.debug.log("Start initializing playback.");
583583
return initializePlayback.call(self);
584584
}
585-
).then(
586-
function (/*done*/) {
587-
self.debug.log("Playback initialized!");
588-
play.call(self);
589-
return load.promise;
590-
}
591585
).then(
592586
function () {
593587
self.debug.log("element loaded!");
@@ -599,6 +593,10 @@ MediaPlayer.dependencies.Stream = function () {
599593
}
600594
initPlayback.call(self);
601595

596+
if (autoPlay) {
597+
self.debug.log("Playback initialized!");
598+
play.call(self);
599+
}
602600
}
603601
);
604602
},

app/js/streaming/StreamController.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
* The copyright in this software is being made available under the BSD License, included below. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
3-
*
3+
*
44
* Copyright (c) 2013, Digital Primates
55
* All rights reserved.
6-
*
6+
*
77
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
88
* • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
99
* • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1010
* • Neither the name of the Digital Primates nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11-
*
11+
*
1212
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1313
*/
1414
MediaPlayer.dependencies.StreamController = function () {
@@ -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 () {
@@ -43,7 +44,7 @@
4344
*
4445
* @param fromVideoModel Currently used video data
4546
* @param toVideoModel New video data to be displayed
46-
*
47+
*
4748
* TODO - move method to appropriate place - VideoModelExtensions??
4849
*/
4950
switchVideoModel = function (fromVideoModel, toVideoModel) {
@@ -88,7 +89,7 @@
8889
},
8990

9091
/*
91-
* Called when more data is buffered.
92+
* Called when more data is buffered.
9293
* Used to determine the time current stream is almost buffered and we can start buffering of the next stream.
9394
* TODO move to ???Extensions class
9495
*/
@@ -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 () {
@@ -253,11 +254,12 @@
253254
self.manifestLoader.load(url).then(
254255
function(manifest) {
255256
self.manifestExt.getPeriodCount(manifest).then(
256-
function(lenght) {
257-
for (var i = 0; i < lenght; i++) {
257+
function(length) {
258+
for (var i = 0; i < length; i++) {
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
}
@@ -292,4 +294,4 @@
292294

293295
MediaPlayer.dependencies.StreamController.prototype = {
294296
constructor: MediaPlayer.dependencies.StreamController
295-
};
297+
};

app/main.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ app.directive('chart', function() {
9494

9595
app.controller('DashController', function($scope, Sources, Notes, Contributors, PlayerLibraries, ShowcaseLibraries) {
9696
var player,
97-
video = document.querySelector(".dash-video-player video"),
98-
context = new Dash.di.DashContext(),
97+
video,
98+
context,
9999
videoSeries = [],
100100
audioSeries = [],
101101
maxGraphPoints = 50,
@@ -312,14 +312,16 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
312312
//
313313
////////////////////////////////////////
314314

315+
video = document.querySelector(".dash-video-player video");
316+
context = new Dash.di.DashContext();
315317
player = new MediaPlayer(context);
316318
$scope.version = player.getVersion();
317319

318320
player.startup();
319321
player.addEventListener("error", onError.bind(this));
320322

321-
player.autoPlay = true;
322323
player.attachView(video);
324+
player.setAutoPlay(true);
323325

324326
////////////////////////////////////////
325327
//

baseline.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@
4242
url = vars.url;
4343
}
4444

45+
video = document.querySelector(".dash-video-player video");
4546
context = new Dash.di.DashContext();
4647
player = new MediaPlayer(context);
47-
player.startup();
4848

49-
player.attachSource(url);
49+
player.startup();
5050

51-
video = document.querySelector(".dash-video-player video"),
52-
player.autoPlay = true;
5351
player.attachView(video);
52+
player.setAutoPlay(false);
53+
54+
player.attachSource(url);
5455
}
5556
</script>
5657

0 commit comments

Comments
 (0)