Re: Examples for API


.Bold { font-weight: bold; }
.Title { font-weight: bold; font-size: 18px; color: #cc3300; }
.Code { border: #8b4513 1px solid; padding-right: 5px; padding-left: 5px;color: #000066; font-family: 'Courier New' , Monospace;background-color: #ff9933; }

Just a minor comment - "Apocalypse" is spelled with an "e" at the end :-)



regards,

John


--- Original Message ---


From : 
"Chris Poppe"<chris.poppe@ugent.be>


To : 
<public-media-annotation@w3.org>


Date : 
2010/05/12 Wednesday AM 4:37:51


Subject : 
Examples for API



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 23:12:54 UTC