


function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        

        case 0:
            return  { "mediaUrl": "open-sharepoint-site-with-designer.wmv",
                      "placeholderImage": "",
                      "chapters": [    
                                        { "title": "[Unknown Value]",   "time": 4.0538708,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.04.0538708.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 9.8203311,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.09.8203311.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 16.3248299,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.16.3248299.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 23.6941996,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.23.6941996.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 30.5394354,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.30.5394354.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 43.9368821,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.43.9368821.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 55.7882585,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.00.55.7882585.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 64.6814966,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.01.04.6814966.jpg"} ,    
                                        { "title": "[Unknown Value]",   "time": 84.8160666,     "imageUrl": "open-sharepoint-site-with-designer_MarkerThumb 00.01.24.8160666.jpg"}                
                                  ] };                                                                
                          
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
}

function StartWithParent(parentId, appId) {
    new StartPlayer_0(parentId);
}

function StartPlayer_0(parentId) {
    this._hostname = EmePlayer.Player._getUniqueName("xamlHost");
    Silverlight.createObjectEx( {   source: 'player.xaml', 
                                        parentElement: $get(parentId ||"divPlayer_0"), 
                                        id:this._hostname, 
                                        properties:{ width:'100%', height:'100%', version:'1.0', background:'transparent', isWindowless:'true' }, 
                                        events:{ onLoad:Function.createDelegate(this, this._handleLoad) } } );
    this._currentMediainfo = 0;      
}
StartPlayer_0.prototype= {
    _handleLoad: function() {
        this._player = $create(   ExtendedPlayer.Player, 
                                  { // properties
                                    autoPlay    : true, 
                                    volume      : 1.0,
                                    muted       : false
                                  }, 
                                  { // event handlers
                                    mediaEnded: Function.createDelegate(this, this._onMediaEnded)
                                  },
                                  null, $get(this._hostname)  ); 
        this._playNextVideo();     
    },    
    _onMediaEnded: function(sender, eventArgs) {
        window.setTimeout( Function.createDelegate(this, this._playNextVideo), 1000);
    },    
    _playNextVideo: function() {
        var cVideos = 1;
        if (this._currentMediainfo<cVideos)
            this._player.set_mediainfo( get_mediainfo( this._currentMediainfo++ ) );    
    }        
}

