yaz/commit

include NPO player

authorMichiel Hildebrand
Fri Dec 16 16:50:30 2011 +0100
committerMichiel Hildebrand
Fri Dec 16 16:50:30 2011 +0100
commitc1f0f3e1815f50ae968eea161b8b485f76f37432
tree863c8545169c638cad9df98082d46f307636986a
parent20623488be11bb52245b642a41c3a283332bc7ae
Diff style: patch stat
diff --git a/api/ugm_ingest.pl b/api/ugm_ingest.pl
index 3bdd51e..a8a131b 100644
--- a/api/ugm_ingest.pl
+++ b/api/ugm_ingest.pl
@@ -51,7 +51,8 @@ http_api_ugm_ingest(Request) :-
 				       [default(''),
 					description('Slug to identify the video')]),
 				  streamURL(StreamURL,
-					    [description('URL of the video stream')]),
+					    [optional(true),
+					     description('URL of the video stream')]),
 				  entries(Entries,
 					      [json_tag_entries,
 					       description('JSON object with the annotations')])
diff --git a/applications/yaz_player.pl b/applications/yaz_player.pl
index c202b53..411d409 100644
--- a/applications/yaz_player.pl
+++ b/applications/yaz_player.pl
@@ -327,7 +327,8 @@ html_video_page_yui(Video, Annotations, StartTime, Options) -->
 						  autoplay:symbol(false),
 						  controls:symbol(true),
 						  start:StartTime,
-						  duration:Duration
+						  duration:Duration,
+						  playerType:npo
 						 })),
 		  \js_new(videoFrames,
 			 'Y.mazzle.VideoFrames'({frameServer:FrameServer,
diff --git a/web/js/videoplayer/ugslplayer.js b/web/js/videoplayer/ugslplayer.js
new file mode 100644
index 0000000..48c1103
--- /dev/null
+++ b/web/js/videoplayer/ugslplayer.js
@@ -0,0 +1,58 @@
+var randomUUID = function() {
+	var s = []
+	var itoh = '0123456789ABCDEF'.split(''); ;
+	for (var i = 0; i <16; i++) s[i] = itoh[Math.floor(Math.random()*0x10)];
+	return s.join('');
+}
+
+function UGSLPlayer(elm, src, config) {
+
+    // Create unique element name
+    var playerId = "ugsl" + randomUUID();
+
+    // Write Silverlight object tag
+    var silverlightObj = ''+
+        '<object id="' + playerId + '" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="620" height="349">' +
+        '<param name="source" value="'+src+'"/>'+
+        '<param name="windowless" value="true"/>'+
+        '<param name="enablehtmlaccess" value="true"/>'+
+        '<param name="onload" value="onSilverlightLoad"/>'+
+        '<param name="initParams" value="'+
+            'embedEnabled=no,playlistEnabled=no,playerId=' + playerId;
+
+            // Add config properties to initParams
+            for (var property in config) {
+                silverlightObj += ',' + property + '=' + config[property];
+            }
+
+    // Finish writing Silverlight object tag
+    silverlightObj += '"/><a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">' +
+        '<img src="/images/logos/nosilverlight.jpg" alt="Microsoft Silverlight niet gevonden" style="border-style: none"/></a></object>';
+
+    // Build Silverlight object into HTML element
+    elm.innerHTML = silverlightObj;
+
+    // Create access methods for config and playlist properties
+    document.getElementById(playerId).getConfigProperty = function(property) {
+        if (this.content != null)
+            return this.content.ugslAccess.getConfigProperty(property);
+    };
+
+    document.getElementById(playerId).setConfigProperty = function(property, value) {
+        if (this.content != null)
+            this.content.ugslAccess.setConfigProperty(property, value);
+    };
+
+    document.getElementById(playerId).getPlaylistProperty = function(property, index) {
+        if (this.content != null)
+            return this.content.ugslAccess.getPlaylistProperty(property, index);
+    };
+
+    document.getElementById(playerId).setPlaylistProperty = function(property, index) {
+        if (this.content != null)
+            this.content.ugslAccess.setPlaylistProperty(property, index);
+    };
+
+    // Return silverlight object
+    return document.getElementById(playerId);
+}
diff --git a/web/js/videoplayer/videoplayer.js b/web/js/videoplayer/videoplayer.js
index 0c115d9..a5b967c 100644
--- a/web/js/videoplayer/videoplayer.js
+++ b/web/js/videoplayer/videoplayer.js
@@ -79,7 +79,7 @@ YUI.add('video-player', function(Y) {
 
 		initializer: function() {
 			if(!this.get("playerType")) {
-				this._setPlayerType();
+				this._guessPlayerType();
 			}
 		},
 
@@ -104,9 +104,12 @@ YUI.add('video-player', function(Y) {
 				this._renderFlashPlayer();
 			} else if(playerType=="silverlight") {
 				this._renderSilverlightPlayer();
+			} else if(playerType=="npo") {
+				this._renderNPOPlayer();
 			}
 		},
 		
+		/* HTML5 */
 		_renderHTMLPlayer : function() {
 			var content = this.get("contentBox"),
 				src = this.get("src"),
@@ -129,6 +132,7 @@ YUI.add('video-player', function(Y) {
 			this.player = document.getElementById(id);//video._node;
 		},
 		
+		/* silverlight */
 		_renderSilverlightPlayer : function() {			
 			// make sure we have the required scripts loaded
 			if(typeof jeroenwijering == "undefined") {
@@ -189,7 +193,8 @@ YUI.add('video-player', function(Y) {
 				Y.later(100, this, this._addSilverlightListeners);
 			}
 		},
-			
+		
+		/* Flash */	
 		_renderFlashPlayer : function() {
  			var url = this.get('filepath')+'swfobject.js';
 			if(typeof swfobject == "undefined") {
@@ -246,6 +251,58 @@ YUI.add('video-player', function(Y) {
 				Y.later(100, this, this._addFlashListeners);
 			}
 		},
+		
+		/* NPO silverlight */
+		_renderNPOPlayer : function() {			
+			// make sure we have the required scripts loaded
+			var filepath = this.get('filepath'),
+				urls = [
+					filepath+'silverlight.js',
+					filepath+'ugslplayer.js'
+				];
+			Y.Get.script(urls, {
+	    		onSuccess: this._embedNPOPlayer,
+				context: this
+			});				
+		},
+		
+		_embedNPOPlayer : function() {
+			var src = this.get("src");
+			
+			Y.log('create npo player');
+
+			var content = this.get("contentBox"),
+				height = this.get("height"),
+				width = this.get("width"),
+				start = this.get("start"),
+				controls = this.get("controls") ? 'yes' : 'no',
+				id = Y.guid();
+		
+			var cfg = {
+				width : width,
+				height : height,
+				volume : '100',
+				showBorder : 'no',
+				embedEnabled : 'yes',
+				controlBarEnabled : controls,
+				viewMode : 'video',
+				//playMode : autoplay ? 'play' : 'pause',
+				playlistEnabled : 'no',
+				playlistAdvanceEnabled : 'no',
+				fragmentID : src
+				//callbackFunction : 'ugCallbackFunction'
+			};
+			
+			var video = content.append(Node.create('<div id="'+id+'"></div>'));	
+			this.player = new UGSLPlayer(document.getElementById(id),
+					'http://embed.player.omroep.nl/slg/ugslplayer.xap',
+					cfg);
+			
+			//this._addSilverlightListeners();
+			//this._silverlightJumpStart();
+		},		
+		
+		/* methods */
 			
 		getDuration : function() {
 			var pt = this.get("playerType"),
@@ -294,7 +351,7 @@ YUI.add('video-player', function(Y) {
 				p = this.player;
 			
 			this.set("src", src);
- 			var pt = this._setPlayerType();
+ 			var pt = this._guessPlayerType();
 			if(pt==oldPt) {
 				if(pt=="silverlight"||pt=="flash") {
 					// TBD something fails here
@@ -345,7 +402,7 @@ YUI.add('video-player', function(Y) {
 			}
 		},
 
-		_setPlayerType : function() {
+		_guessPlayerType : function() {
 			// guess required playerType based on extension
 			if(this.get("src")) {
 				var pt = null,