Skip to content

Commit

Permalink
Merge pull request #1134 from boushley/1023-namespace
Browse files Browse the repository at this point in the history
Migrate globals into dashjs namespace
  • Loading branch information
Dan Sparacio authored and Dan Sparacio committed Feb 5, 2016
2 parents f885b71 + d72a68d commit 3b91821
Show file tree
Hide file tree
Showing 24 changed files with 78 additions and 71 deletions.
12 changes: 6 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = function (grunt) {
options: {
browserifyOptions: {
debug: true,
standalone: 'MediaPlayer'
standalone: 'dashjs.MediaPlayer'
},
plugin: [
['browserify-derequire']
Expand All @@ -137,7 +137,7 @@ module.exports = function (grunt) {
options: {
browserifyOptions: {
debug: true,
standalone: 'Protection'
standalone: 'dashjs.Protection'
},
plugin: [
['browserify-derequire']
Expand All @@ -152,7 +152,7 @@ module.exports = function (grunt) {
options: {
browserifyOptions: {
debug: true,
standalone: 'MetricsReporting'
standalone: 'dashjs.MetricsReporting'
},
plugin: [
['browserify-derequire']
Expand All @@ -162,11 +162,11 @@ module.exports = function (grunt) {
},
all: {
files: {
'build/temp/dash.all.debug.js': ['src/All.js']
'build/temp/dash.all.debug.js': ['index.js']
},
options: {
browserifyOptions: {
debug: true,
debug: true
},
plugin: [
['browserify-derequire']
Expand All @@ -177,7 +177,7 @@ module.exports = function (grunt) {

watch: {
files: {
'build/temp/dash.all.debug.js': ['src/All.js']
'build/temp/dash.all.debug.js': ['index.js']
},
options: {
watch: true,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Now comes the good stuff. We need to create a MediaPlayer and initialize it. We
``` js
(function(){
var url = "http://dash.edgesuite.net/envivio/Envivio-dash2/manifest.mpd";
var player = MediaPlayer().create();
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#videoPlayer"), url, true);
})();
```
Expand All @@ -73,7 +73,7 @@ When it is all done, it should look similar to this:
<script>
(function(){
var url = "http://dash.edgesuite.net/envivio/Envivio-dash2/manifest.mpd";
var player = MediaPlayer().create();
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#videoPlayer"), url, true);
})();
</script>
Expand Down
20 changes: 10 additions & 10 deletions contrib/akamai/controlbar/ControlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ var ControlBar = function(dashjsMediaPlayer) {
videoContainer = player.getVideoContainer();
captionBtn.classList.add("hide");

player.on(MediaPlayer.events.PLAYBACK_STARTED, onPlayStart);
player.on(MediaPlayer.events.PLAYBACK_PAUSED, onPlaybackPaused);
player.on(MediaPlayer.events.PLAYBACK_TIME_UPDATED, onPlayTimeUpdate);
player.on(MediaPlayer.events.PLAYBACK_SEEKED, onSeeked);
player.on(MediaPlayer.events.TEXT_TRACKS_ADDED, onTracksAdded);
player.on(dashjs.MediaPlayer.events.PLAYBACK_STARTED, onPlayStart);
player.on(dashjs.MediaPlayer.events.PLAYBACK_PAUSED, onPlaybackPaused);
player.on(dashjs.MediaPlayer.events.PLAYBACK_TIME_UPDATED, onPlayTimeUpdate);
player.on(dashjs.MediaPlayer.events.PLAYBACK_SEEKED, onSeeked);
player.on(dashjs.MediaPlayer.events.TEXT_TRACKS_ADDED, onTracksAdded);

playPauseBtn.addEventListener("click", onPlayPauseClick);
muteBtn.addEventListener("click", onMuteClick);
Expand Down Expand Up @@ -435,11 +435,11 @@ var ControlBar = function(dashjsMediaPlayer) {
seekbar.removeEventListener("change", onSeekBarChange);
seekbar.removeEventListener("input", onSeeking);
volumebar.removeEventListener("input", setVolume);
player.off(MediaPlayer.events.PLAYBACK_STARTED, onPlayStart);
player.off(MediaPlayer.events.PLAYBACK_PAUSED, onPlaybackPaused);
player.off(MediaPlayer.events.PLAYBACK_TIME_UPDATED, onPlayTimeUpdate);
player.off(MediaPlayer.events.PLAYBACK_SEEKED, onSeeked);
player.off(MediaPlayer.events.TEXT_TRACKS_ADDED, onTracksAdded);off
player.off(dashjs.MediaPlayer.events.PLAYBACK_STARTED, onPlayStart);
player.off(dashjs.MediaPlayer.events.PLAYBACK_PAUSED, onPlaybackPaused);
player.off(dashjs.MediaPlayer.events.PLAYBACK_TIME_UPDATED, onPlayTimeUpdate);
player.off(dashjs.MediaPlayer.events.PLAYBACK_SEEKED, onSeeked);
player.off(dashjs.MediaPlayer.events.TEXT_TRACKS_ADDED, onTracksAdded);off
document.removeEventListener("fullscreenchange", onFullScreenChange);
document.removeEventListener("MSFullscreenChange", onFullScreenChange);
document.removeEventListener("mozfullscreenchange", onFullScreenChange);
Expand Down
20 changes: 14 additions & 6 deletions src/All.js → index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

import MediaPlayer from './streaming/MediaPlayer.js';
import Protection from './streaming/protection/Protection.js';
import MetricsReporting from './streaming/metrics/MetricsReporting.js';
import MediaPlayer from './src/streaming/MediaPlayer.js';
import Protection from './src/streaming/protection/Protection.js';
import MetricsReporting from './src/streaming/metrics/MetricsReporting.js';
import MediaPlayerFactory from './src/streaming/MediaPlayerFactory.js';


// Shove both of these into the global scope
var context = window || global;
context.MediaPlayer = MediaPlayer;
context.Protection = Protection;
context.MetricsReporting = MetricsReporting;

context.dashjs = {
MediaPlayer: MediaPlayer,
Protection: Protection,
MetricsReporting: MetricsReporting,
MediaPlayerFactory: MediaPlayerFactory
};

export default context.dashjs;
export { MediaPlayer, Protection, MetricsReporting, MediaPlayerFactory };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dashjs",
"version": "2.0.0",
"description": "A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.",
"main": "dist/dash.all.min.js",
"main": "index.js",
"scripts": {
"test": "mocha --require mochahook",
"prepublish": "grunt prepublish",
Expand Down
2 changes: 1 addition & 1 deletion samples/ad-insertion/inband.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h3 class="panel-title">Working principle</h3>
<script> (function () {
$.get("http://se-mashup.fokus.fraunhofer.de:8080/getSession", function (data) {
var url = "http://se-mashup.fokus.fraunhofer.de:8080/dash/assets/adinsertion-samples/events/inband/dash.mpd?sid=" + data.sessionID;
var player = MediaPlayer().create();
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#vid"), url, true);
})
})();
Expand Down
2 changes: 1 addition & 1 deletion samples/ad-insertion/inline.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h3 class="panel-title">Working principle</h3>
<script> (function () {
$.get("http://se-mashup.fokus.fraunhofer.de:8080/getSession", function (data) {
var url = "http://se-mashup.fokus.fraunhofer.de:8080/dash/assets/adinsertion-samples/events/inline/dash.mpd?sid=" + data.sessionID;
var player = MediaPlayer().create();
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#vid"), url, true);
})
})();
Expand Down
4 changes: 2 additions & 2 deletions samples/ad-insertion/js/scte.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Created by dsi on 11.05.2015.
*/
(function() {
var player = MediaPlayer().create();
playerAd = MediaPlayer().create();
var player = dashjs.MediaPlayer().create();
playerAd = dashjs.MediaPlayer().create();
contentUrl = 'http://vm2.dashif.org/livesim/scte35_1/testpic_2s/Manifest.mpd ',
adUrl = 'http://dash.edgesuite.net/fokus/adinsertion-samples/scte/dash.mpd',
currentlyAd = false;
Expand Down
2 changes: 1 addition & 1 deletion samples/ad-insertion/xlink.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h3 class="panel-title">Working principle</h3>

<script>
(function () {
var player = MediaPlayer().create();
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#vid"));

document.getElementById('xlink-two-per').addEventListener('click', function () {
Expand Down
2 changes: 1 addition & 1 deletion samples/captioning/caption_vtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
video = document.querySelector(".dash-video-player video"),
player;

player = MediaPlayer({}).create();
player = dashjs.MediaPlayer({}).create();
player.initialize(video, url, true);
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion samples/captioning/multi-track-captions.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var url = FRAGMENTED_CAPTION_URL;

videoElement = document.querySelector(".videoContainer video");
player = MediaPlayer({}).create();
player = dashjs.MediaPlayer().create();
player.initialize(videoElement, url, true);
controlbar = new ControlBar(player); // Checkout ControlBar.js for more info on how to target/add text tracks to UI
controlbar.initialize();
Expand Down
2 changes: 1 addition & 1 deletion samples/captioning/ttml-ebutt-sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
videoElement = document.querySelector(".videoContainer video");
TTMLRenderingDiv = document.querySelector("#ttml-rendering-div");

player = MediaPlayer({}).create();
player = dashjs.MediaPlayer().create();
player.initialize(videoElement, url, true);
player.attachTTMLRenderingDiv(TTMLRenderingDiv);
controlbar = new ControlBar(player); // Checkout ControlBar.js for more info on how to target/add text tracks to UI
Expand Down
2 changes: 1 addition & 1 deletion samples/chromecast/receiver/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function ReceiverController($scope) {

var video = document.querySelector(".dash-video-player video");

player = MediaPlayer({}).create();
player = dashjs.MediaPlayer().create();
player.initialize(video, url, true)
//player.setIsLive(isLive);
$scope.showSpinner = false;
Expand Down
22 changes: 11 additions & 11 deletions samples/dash-if-reference-player/app/eme-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
////////////////////////////////////////

video = document.querySelector(".dash-video-player video");
player = MediaPlayer({}).create();
player = dashjs.MediaPlayer().create();
player.initialize(video, null, true);
player.on(MediaPlayer.events.ERROR, onError.bind(this));
player.on(dashjs.MediaPlayer.events.ERROR, onError.bind(this));
player.attachVideoContainer(document.getElementById("videoContainer"));
controlbar = new ControlBar(player, video);
controlbar.initialize();
Expand Down Expand Up @@ -174,7 +174,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
$scope.drmData.push(data);
$scope.safeApply();

player.on(MediaPlayer.events.KEY_SYSTEM_SELECTED, function(e) {
player.on(dashjs.MediaPlayer.events.KEY_SYSTEM_SELECTED, function(e) {
if (!e.error) {
data.ksconfig = e.data.ksConfiguration;
} else {
Expand All @@ -184,7 +184,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}, $scope);


player.on(MediaPlayer.events.KEY_SESSION_CREATED, function(e) {
player.on(dashjs.MediaPlayer.events.KEY_SESSION_CREATED, function(e) {
if (!e.error) {
var persistedSession = findSession(e.data.getSessionID());
if (persistedSession) {
Expand All @@ -205,7 +205,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}, $scope);


player.on(MediaPlayer.events.KEY_SESSION_REMOVED, function(e) {
player.on(dashjs.MediaPlayer.events.KEY_SESSION_REMOVED, function(e) {
if (!e.error) {
var session = findSession(e.data);
if (session) {
Expand All @@ -219,7 +219,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}, $scope);


player.on(MediaPlayer.events.KEY_SESSION_CLOSED, function(e) {
player.on(dashjs.MediaPlayer.events.KEY_SESSION_CLOSED, function(e) {
if (!e.error) {
for (var i = 0; i < data.sessions.length; i++) {
if (data.sessions[i].sessionID === e.data) {
Expand All @@ -233,7 +233,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
$scope.safeApply();
}, $scope);

player.on(MediaPlayer.events.KEY_STATUSES_CHANGED, function(e) {
player.on(dashjs.MediaPlayer.events.KEY_STATUSES_CHANGED, function(e) {
var session = findSession(e.data.getSessionID());
if (session) {
var toGUID = function(uakey) {
Expand Down Expand Up @@ -267,7 +267,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}
}, $scope);

player.on(MediaPlayer.events.KEY_MESSAGE, function(e) {
player.on(dashjs.MediaPlayer.events.KEY_MESSAGE, function(e) {
var session = findSession(e.data.sessionToken.getSessionID());
if (session) {
session.lastMessage = "Last Message: " + e.data.message.byteLength + " bytes";
Expand All @@ -281,7 +281,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}
}, $scope);

player.on(MediaPlayer.events.LICENSE_REQUEST_COMPLETE, function(e) {
player.on(dashjs.MediaPlayer.events.LICENSE_REQUEST_COMPLETE, function(e) {
if (!e.error) {
var session = findSession(e.data.sessionToken.getSessionID());
if (session) {
Expand All @@ -300,7 +300,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
// Listen for protection system creation/destruction by the player itself. This will
// only happen in the case where we do not not provide a ProtectionController
// to the player via MediaPlayer.attachSource()
player.on(MediaPlayer.events.PROTECTION_CREATED, function (e) {
player.on(dashjs.MediaPlayer.events.PROTECTION_CREATED, function (e) {
var data = addDRMData(e.manifest, e.controller);
data.isPlaying = true;
for (var i = 0; i < $scope.drmData.length; i++) {
Expand All @@ -310,7 +310,7 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
}
$scope.safeApply();
}, $scope);
player.on(MediaPlayer.events.PROTECTION_DESTROYED, function (e) {
player.on(dashjs.MediaPlayer.events.PROTECTION_DESTROYED, function (e) {
for (var i = 0; i < $scope.drmData.length; i++) {
if ($scope.drmData[i].manifest.url === e.data) {
$scope.drmData.splice(i, 1);
Expand Down
12 changes: 6 additions & 6 deletions samples/dash-if-reference-player/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,16 +561,16 @@ app.controller('DashController', function($scope, Sources, Notes, Contributors,
////////////////////////////////////////

video = document.querySelector(".dash-video-player video");
player = MediaPlayer().create();
player = dashjs.MediaPlayer().create();

$scope.version = player.getVersion();

player.initialize();
player.on(MediaPlayer.events.ERROR, onError.bind(this));
player.on(MediaPlayer.events.METRIC_CHANGED, metricChanged.bind(this));
player.on(MediaPlayer.events.METRIC_UPDATED, metricUpdated.bind(this));
player.on(MediaPlayer.events.PERIOD_SWITCH_COMPLETED, streamSwitch.bind(this));
player.on(MediaPlayer.events.STREAM_INITIALIZED, streamInitialized.bind(this));
player.on(dashjs.MediaPlayer.events.ERROR, onError.bind(this));
player.on(dashjs.MediaPlayer.events.METRIC_CHANGED, metricChanged.bind(this));
player.on(dashjs.MediaPlayer.events.METRIC_UPDATED, metricUpdated.bind(this));
player.on(dashjs.MediaPlayer.events.PERIOD_SWITCH_COMPLETED, streamSwitch.bind(this));
player.on(dashjs.MediaPlayer.events.STREAM_INITIALIZED, streamInitialized.bind(this));
player.attachView(video);
player.attachVideoContainer(document.getElementById("videoContainer"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
</style>

<body onload="MediaPlayer.MediaPlayerFactory.createAll()">
<body onload="dashjs.MediaPlayerFactory.createAll()">
<div>
<video class="dashjs-player" autoplay controls>
<source src="http://dash.edgesuite.net/envivio/EnvivioDash3/manifest.mpd" type="application/dash+xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
</style>

<body onload="MediaPlayer.MediaPlayerFactory.createAll()">
<body onload="dashjs.MediaPlayerFactory.createAll()">
<div>
<video class="dashjs-player" autoplay src="http://dash.edgesuite.net/envivio/EnvivioDash3/manifest.mpd" controls="true"/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@

// Example specifying only the video element, where the video element has a child source element
video = document.querySelector("#video1");
player = MediaPlayer.MediaPlayerFactory.create(video);
player = dashjs.MediaPlayerFactory.create(video);

// Example specifying only the video element, where the video element has a src attribute
video = document.querySelector("#video2");
player = MediaPlayer.MediaPlayerFactory.create(video);
player = dashjs.MediaPlayerFactory.create(video);

//Example adding video and source
video = document.querySelector("#video3");
source = document.createElement("source");
source.src = "http://dash.edgesuite.net/envivio/EnvivioDash3/manifest.mpd";
source.type = "application/dash+xml";
player = MediaPlayer.MediaPlayerFactory.create(video, source);
player = dashjs.MediaPlayerFactory.create(video, source);

//Example adding video, source and context
video = document.querySelector("#video4");
source = document.createElement("source");
source.src = "http://dash.edgesuite.net/envivio/EnvivioDash3/manifest.mpd";
source.type = "application/dash+xml";
context = {}
player = MediaPlayer.MediaPlayerFactory.create(video, source, context);
player = dashjs.MediaPlayerFactory.create(video, source, context);
}
</script>
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

function init()
{
player = MediaPlayer.MediaPlayerFactory.create(document.querySelector(".dashjs-player"));
player = dashjs.MediaPlayerFactory.create(document.querySelector(".dashjs-player"));
setInterval(updateStats,500)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
</style>

<body onload="MediaPlayer.MediaPlayerFactory.createAll()">
<body onload="dashjs.MediaPlayerFactory.createAll()">
<div>
<video class="dashjs-player" autoplay preload="none" controls="true">
<source src="http://dash.edgesuite.net/envivio/EnvivioDash3/manifest.mpd" type="application/dash+xml"/>
Expand Down
Loading

0 comments on commit 3b91821

Please sign in to comment.