W3C home > Mailing lists > Public > public-media-annotation@w3.org > May 2010

Examples for API

From: Chris Poppe <chris.poppe@ugent.be>
Date: Tue, 11 May 2010 21:37:51 +0200
Message-ID: <20100511213751.14073rzp673hyj2n@webmail.ugent.be>
To: public-media-annotation@w3.org
Dear all,

Here are a few use cases for which we wrote WebIDL code for to be  
included in the introduction of the API doc.

If there are no objections this will be added.



  Example 1:
Return the name of the director of the movie "Apocalyps now"


//assume that the video elements in HTML5 inherit from the  
MediaResource interface
  video = document.getElementsByTagName("video");


  //search the video's for the one with title "Apocalyps now"
  for(i=0; i<video.length; i++)
  {
  	//request for the titles of the video
  	titles = video[i].getProperty("title");
  	for(j = 0; j<titles.length; j++)
  	{
  		//check if the title matches
  		if(titles[j].value == "Apocalyps Now")
  		{
  			//request for the director of the video
  			director =
  video[i].getProperty("contributor","","","director");

  		}
  	}
  }




Example 2: Retrieve the title of the second song from the
  album "Josuha Tree" by U2.

  //somehow get the mediaResource object that represents the corresponding
  album
  album = document.getElementById("JosuhaTree_U2");
//get the id of the second song using the fragments property
  trackid = album.getProperty("Fragments","","","Song")[1].id;

  //use this identifier to get the mediaResource object that represents the
  track
  mediaResource = new MediaResource();
  mediaResource.selectMediaResource(trackid);

  //get the title of the track
  title = mediaResource.getProperty("Title")[0].value;


  Example 3: Return the copyright of the movie "Planet of the apes"

  //somehow get the mediaResource object that represents the movie (e.g., see
  first example)
  movie = document.getElementById("Planet_of_the_apes_id");
  copyright = movie.getProperty("copyright","","","","en-us")[0].statement;



  Example 4: Return the genre of the movie "Apocalyps Now"


  //somehow get the mediaResource object that represents the movie (e.g., see
  first example)
  movie = document.getElementById("Apocalyps_Now_id");
  genre = movie.getProperty("genre","","","","en-us");

  /*Resulting in:
  genre[0].value = "Action";
  genre[1].value = "Drama";
  */



-- 
Ghent University - Multimedia Lab
Sint-Pietersnieuwstraat 41
B-9000 Ghent, Belgium

tel: +32 9 264 89 17
fax: +32 9 264 35 94
e-mail: Chris.Poppe@ugent.be

URL: http://multimedialab.elis.ugent.be
Received on Tuesday, 11 May 2010 19:38:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 May 2010 19:38:21 GMT