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

Re: Examples for API

From: StrassnerˇˇJohn Charles <johns@postech.ac.kr>
Date: Wed, 12 May 2010 08:12:11 +0900 (KST)
Message-ID: <28284033.1273619531162.JavaMail.root@mail1.postech.ac.kr>
To: Chris Poppe <chris.poppe@ugent.be>, <public-media-annotation@w3.org>

.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 - &quot;Apocalypse&quot; is spelled with an &quot;e&quot; at the end :-)



regards,

John


--- Original Message ---


From : 
&quot;Chris Poppe&quot;&lt;chris.poppe@ugent.be&gt;


To : 
&lt;public-media-annotation@w3.org&gt;


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 &quot;Apocalyps now&quot; 





//assume that the video elements in HTML5 inherit from the 

MediaResource interface 

video = document.getElementsByTagName(&quot;video&quot;); 





//search the video's for the one with title &quot;Apocalyps now&quot; 

for(i=0; i&lt;video.length; i++) 

{ 

//request for the titles of the video 

titles = video[i].getProperty(&quot;title&quot;); 

for(j = 0; j&lt;titles.length; j++) 

{ 

//check if the title matches 

if(titles[j].value == &quot;Apocalyps Now&quot;) 

{ 

//request for the director of the video 

director = 

video[i].getProperty(&quot;contributor&quot;,&quot;&quot;,&quot;&quot;,&quot;director&quot;); 



} 

} 

} 









Example 2: Retrieve the title of the second song from the 

album &quot;Josuha Tree&quot; by U2. 



//somehow get the mediaResource object that represents the corresponding 

album 

album = document.getElementById(&quot;JosuhaTree_U2&quot;); 

//get the id of the second song using the fragments property 

trackid = album.getProperty(&quot;Fragments&quot;,&quot;&quot;,&quot;&quot;,&quot;Song&quot;)[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(&quot;Title&quot;)[0].value; 





Example 3: Return the copyright of the movie &quot;Planet of the apes&quot; 



//somehow get the mediaResource object that represents the movie (e.g., see 

first example) 

movie = document.getElementById(&quot;Planet_of_the_apes_id&quot;); 

copyright = movie.getProperty(&quot;copyright&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;en-us&quot;)[0].statement; 







Example 4: Return the genre of the movie &quot;Apocalyps Now&quot; 





//somehow get the mediaResource object that represents the movie (e.g., see 

first example) 

movie = document.getElementById(&quot;Apocalyps_Now_id&quot;); 

genre = movie.getProperty(&quot;genre&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;en-us&quot;); 



/*Resulting in: 

genre[0].value = &quot;Action&quot;; 

genre[1].value = &quot;Drama&quot;; 

*/ 







-- 

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 May 2010 23:12:54 GMT