yaz/commit

add forward to gardening when game finished

authorMichiel Hildebrand
Mon Feb 7 20:50:43 2011 +0100
committerMichiel Hildebrand
Mon Feb 7 20:50:43 2011 +0100
commit8b8a70cef7ffa879969bec9565ed100a42686ef7
tree3c3e51f872a01dcfbe4d8b3ee4639db2ac3b449b
parent768bd424fad2931dfa594824edc99ce312b43d46
Diff style: patch stat
diff --git a/applications/yaz_cgarden.pl b/applications/yaz_cgarden.pl
index 6a8823e..e18e573 100644
--- a/applications/yaz_cgarden.pl
+++ b/applications/yaz_cgarden.pl
@@ -45,7 +45,8 @@ http_yaz_cgarden(Request) :-
 	user_property(User0, url(CurrentUser)),
 	http_parameters(Request,
 			[ video(Video,
-				[description('Current video')]),
+				[optional(true),
+				 description('Current video')]),
 			  process(Process,
 			       [optional(true),
 				desription('When set only annotations within this process are shown')]),
@@ -56,6 +57,13 @@ http_yaz_cgarden(Request) :-
 				    [default(10000),
 				     description('Use only confirmed tags when set to true')])
   			]),
+	(   var(Video),
+	    var(Process)
+	->  fail % proper error
+	;   var(Video)
+	->  rdf(Process,opmv:used,Video)
+	;   true
+	),
 	Options = [process(Process),
 		   user(User),
 		   interval(Interval)
@@ -122,7 +130,7 @@ html_video_page_yui(Video, User, Annotations, StartTime, _Options) -->
 	  http_absolute_location(js('videoplayer/videoplayer.js'), VideoPlayer, []),
 	  http_absolute_location(js('tagcarousel/tagcarousel.js'), TagCarousel, []),
 	  %setting(request_interval, RequestInterval),
-	  %http_location_by_id(http_reconcile, ReconcileServer),
+	  http_location_by_id(http_reconcile, ReconcileServer),
   	  annotation_to_json(Annotations, JSONTags)
    	},
 	html_requires(js('videoplayer/swfobject.js')),
@@ -156,8 +164,8 @@ html_video_page_yui(Video, User, Annotations, StartTime, _Options) -->
  		  \js_yui3_on(tagCarousel, itemSelect, \js_tag_select),
  		  \js_yui3_on(tagCarousel, itemConfirm, \js_confirm(User)),
 		  \js_support_functions(User),
-		  \js_call('tagCarousel.reconcile'('http://standard-reconcile.freebaseapps.com/reconcile'))
-		  %\js_call('tagCarousel.reconcile'(ReconcileServer))
+		  %\js_call('tagCarousel.reconcile'('http://standard-reconcile.freebaseapps.com/reconcile'))
+		  \js_call('tagCarousel.reconcile'(ReconcileServer))
 		  /*\js_call('Y.later'(RequestInterval, symbol('Y'),
 				     symbol(fetchData), symbol({}), symbol(true)))*/
    		]).
diff --git a/applications/yaz_game.pl b/applications/yaz_game.pl
index 4894145..e5ab5da 100644
--- a/applications/yaz_game.pl
+++ b/applications/yaz_game.pl
@@ -40,6 +40,8 @@
 	   'Expect delay in load of page and start of Video (in seconds)').
 :- setting(gamestart, oneof([all,creator,none,false]), creator,
 	   'Determines who can start the game').
+:- setting(garden, oneof([player,sgarden,mgarden,cgarden,false]), cgarden,
+	   'Redirect to gardening when video is finished').
 
 :- dynamic
 	player_score/3.
@@ -47,6 +49,12 @@
 :- rdf_meta
         cond_object_assert(r,r,o,r).
 
+
+channel('http://nos.nl/video/217191-het-nieuws-in-60-seconden-1430-uur.html',
+	video('nos_journaal_07022011.flv'),
+	'NOS journaal 7 Feb 2011',
+	60).
+
 channel('http://g.bbcredux.com/programme/bbcone/2011-02-05/12-00-00',
 	video('bbc_news_05022011.flv'),
         'BBC News 5 Feb 2011 12:00',
@@ -321,6 +329,7 @@ html_page_yui(Game, URL, User, PlayHead, Players, Tags) -->
 	  http_absolute_location(js('game/input.js'), GameInput, []),
 	  http_absolute_location(js('game/players.js'), GamePlayers, []),
 	  setting(request_interval, RequestInterval),
+	  setting(garden, Garden),
 	  video_source(URL, Video)
 	},
 	html_requires(js('videoplayer/swfobject.js')),
@@ -356,8 +365,9 @@ html_page_yui(Game, URL, User, PlayHead, Players, Tags) -->
 		  \js_call('Y.later'(RequestInterval, symbol('Y'),
 				     symbol(fetchData), symbol({}), symbol(true))),
 		  \js_call('videoPlayer.render'('#videoplayer')),
-		  \js_yui3_on(gameInput, addTag, addTag)
- 		]).
+		  \js_yui3_on(gameInput, addTag, addTag),
+		  \js_yui3_on(videoPlayer, end, \js_video_end(Garden, Game))
+  		]).
 
 js_support_functions(Game, User) -->
 	{ http_location_by_id(http_game_add_tag, AddTag),
@@ -390,6 +400,14 @@ js_support_functions(Game, User) -->
     gameInput.updateTags(r.tags);\n'
 			  ]).
 
+js_video_end(false, _) --> !.
+js_video_end(Garden, Process) -->
+	{ http_absolute_location(yaz(Garden), URL, [])
+	},
+	js_function([],
+		    \[
+'    window.location.href = "',URL,'?process=',Process,'"'
+		    ]).
 
 		 /*******************************
 		 *	    game events		*
diff --git a/applications/yaz_new_user.pl b/applications/yaz_new_user.pl
index 5a2dc2e..5d4e633 100644
--- a/applications/yaz_new_user.pl
+++ b/applications/yaz_new_user.pl
@@ -17,7 +17,8 @@
 
 :- http_handler(yaz(start), http_yaz_start, []).
 
-video(1, 'http://g.bbcredux.com/programme/bbcone/2011-02-05/12-00-00').
+video(1, 'http://nos.nl/video/217191-het-nieuws-in-60-seconden-1430-uur.html').
+%video(1, 'http://g.bbcredux.com/programme/bbcone/2011-02-05/12-00-00').
 
 %%	http_yaz_start(+Request)
 %
diff --git a/web/js/videoplayer/player.swf b/web/js/videoplayer/player.swf
index 2922419..a8e485f 100644
Binary files a/web/js/videoplayer/player.swf and b/web/js/videoplayer/player.swf differ
diff --git a/web/js/videoplayer/videoplayer.js b/web/js/videoplayer/videoplayer.js
index 19fffa7..0c115d9 100644
--- a/web/js/videoplayer/videoplayer.js
+++ b/web/js/videoplayer/videoplayer.js
@@ -63,6 +63,7 @@ YUI.add('video-player', function(Y) {
 		},
 		extensions : {
 			value: {
+				mp4:"flash",
 				flv:"flash",
 				asf:"silverlight",
 				wmv:"silverlight"
@@ -416,6 +417,9 @@ YUI.add('video-player', function(Y) {
 				this.set("state", newState);
 				Y.log('state: '+newState);
 				this.fire("stateChanged", {oldstate:oldState, newstate:newState});
+				if(newState=="COMPLETED") {
+					this.fire("end");
+				}
 			}
 		},