#14 - Visualizzare informazioni integrative di un Video

L'oggetto MediaElement può accettare come sorgente un file di tipo ASX (Advanced Stream Redirector), un file XML strutturato con nodi e attributi da utilizzare come informazioni integrative al contenuto multimediale da riprodurre:

<asx version='3.0'> 
    <entry> 
        <title>Titolo del Video1</title> 
        <AUTHOR>Nome e Cognome dell'autore</AUTHOR> 
        <MOREINFO HREF="http://www.silverlight.com/" /> 
        <ref href="video1.wmv"/> 
    </entry> 
</asx>

Tali informazioni possono essere recuperate a seguito dell'evento onMediaOpened attraverso la proprietà Attributes dell'oggetto MediaElement:

var attribute; 
var _i = 0; 
var asxTitle = "title"; 
var asxAuthor = "author"; 
var asxUrl = "infourl"; 
 
var mediaTitle = null; 
var authorName = null; 
var authorURL = null; 
 
while(_i < this.mediaElement1.Attributes.count) 
{ 
    attribute = this.mediaElement1.Attributes.getItem(_i); 
     
    if(attribute.Name.toLowerCase() == asxTitle) 
    { 
        mediaTitle = attribute.Value; 
    } 
    if(attribute.Name.toLowerCase() == asxAuthor) 
    { 
        authorName = attribute.Value; 
    } 
    if(attribute.Name.toLowerCase() == asxUrl) 
    { 
        authorURL = attribute.Value; 
    } 
    _i++; 
}

Per recuperare il valore una specifica informazione è sufficiente eseguire un ciclo nella collezione di tipo MediaAttribute, cercare il nodo corrispondente effettuando il confronto con il nome dell'informazione desiderata ed accedere alla relativa proprietà Value.

Per approfondimenti: http://msdn.microsoft.com/en-us/library/ms925291.aspx

IL CONTENUTO
SCRIPT VIA E-MAIL

Iscriviti alle nostre newsletter unoscript@lgiorno e Xcript per ricevere gli script via e-mail.

MEDIA
IN EVIDENZA
MISC