yaz/commit

handlers for NPO player

authorMichiel Hildebrand
Mon Dec 19 17:30:28 2011 +0100
committerMichiel Hildebrand
Mon Dec 19 17:30:28 2011 +0100
commit2ab673ab6215937c5950541582264d0222b20126
tree2935ae62108d8d7c6b7a500655eb9dc3bd5f6eaf
parentbb9089462c4b20accd74abbbd9a90e77fc3415b9
Diff style: patch stat
diff --git a/web/js/videoplayer/videoplayer.js b/web/js/videoplayer/videoplayer.js
index a5b967c..7ee0748 100644
--- a/web/js/videoplayer/videoplayer.js
+++ b/web/js/videoplayer/videoplayer.js
@@ -277,7 +277,7 @@ YUI.add('video-player', function(Y) {
 				start = this.get("start"),
 				controls = this.get("controls") ? 'yes' : 'no',
 				id = Y.guid();
-		
+			
 			var cfg = {
 				width : width,
 				height : height,
@@ -290,17 +290,50 @@ YUI.add('video-player', function(Y) {
 				playlistEnabled : 'no',
 				playlistAdvanceEnabled : 'no',
 				fragmentID : src
-				//callbackFunction : 'ugCallbackFunction'
+				//callbackFunction : 
 			};
 			
 			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();
-		},		
+		},
+		
+		_ugCallbackFunction : function(eventType, args) {
+			if (eventType = 'PropertyChanged') {
+				console.log('property %s changed from %s to %s', args.name, args.oldvalue, args.newvalue);
+				if(args.name=='seekTime') {
+					this._changeCurrentTime(arg.newvalue);
+				}
+				else if(args.name=='videostatus') {
+					
+				}
+				/*
+				if (args.name == 'seekTime' || args.name == 'videoStatus') {
+					var streamStatus = vp.player.getConfigProperty('videoStatus');
+					if (streamStatus != 'playing') {
+						return;
+					}
+					var seekTime = Utils.parseTime(vp.player
+							.getConfigProperty('seekTime'));
+					var startTime = Utils.parseTime(vp.player
+							.getConfigProperty('startTime'));
+					var endTime = Utils.parseTime(vp.player
+							.getConfigProperty('endTime'));
+					if (!startTime || !endTime) {
+						return;
+					}
+					var duration = endTime - startTime;
+					var elapsed = seekTime;
+					if (elapsed > duration - 5) {
+						vp.nearEnd = true;
+					}
+					vp.onTick(elapsed, duration);
+				} else if (args.name == 'playMode' && args.newvalue == 'pause' && vp.nearEnd) {
+					vp.dispatchEvents("fragmentEnd");
+				}*/
+			}
+		},
 		
 		/* methods */
 			
@@ -336,6 +369,13 @@ YUI.add('video-player', function(Y) {
 			if(pt=="silverlight") {
 				p.sendEvent('SCRUB', time);
 				if(play) { this.play(); }
+			} else if(pt=="npo") {
+				var h = parseInt(time/3600) % 24,
+					m = parseInt(time/60) % 60,
+					s = time % 60,
+					hms = (h<10 ? "0"+h : h) + ":" + (m<10 ? "0"+m : m) + ":" + (s<10 ? "0"+s : s);
+				console.log(hms);	
+				p.content.ugslAccess.setConfigProperty('seekTime', hms);
 			} else if(pt=="flash"){
 				p.sendEvent('SEEK', time);
 				if(!play) { Y.later(100, this, this.pause); }
@@ -408,11 +448,15 @@ YUI.add('video-player', function(Y) {
 				var pt = null,
 					src = this.get("src"),
 					extensions = this.get("extensions"),
-					videoType = src.substr(src.length-3, 3);
-
-				if(extensions[videoType]) {
-					pt = extensions[videoType];
-				} else {
+					ext = src.substr(src.length-3, 3);
+				
+				if(parseInt(src)) {
+					pt = 'npo';
+				}
+				else if(extensions[ext]) {
+					pt = extensions[ext];
+				} 
+				else {
 					pt = "html";
 				}
 			}