
 



function StartWithParent(parentId, appId) {
    new StartPlayer_0(parentId);
}

function StartPlayer_0(parentId) {
    this._hostname = EePlayer.Player._getUniqueName("xamlHost");
    Silverlight.createObjectEx( {   source: '/canada/home/gmcms/inc/silverlight/player.xaml', 
                                        parentElement: $get(parentId ||"divPlayer_0"), 
                                        id:this._hostname, 
                                        properties:{ width:'400', height:'246', version:'1.0', background:document.body.style.backgroundColor, isWindowless:'true' }, 
                                        events:{ onLoad:Function.createDelegate(this, this._handleLoad) } } );
    this._currentMediainfo = 0;      
}
StartPlayer_0.prototype= {
    _handleLoad: function() {
        this._player = $create(   ExtendedPlayer.Player, 
                                  { // properties
                                    autoPlay    : false, 
                                    volume      : 1.0,
                                    muted       : false
                                  }, 
                                  { // event handlers
                                    mediaEnded: Function.createDelegate(this, this._onMediaEnded),
                                    mediaFailed: Function.createDelegate(this, this._onMediaFailed)
                                  },
                                  null, $get(this._hostname)  ); 
        this._playNextVideo();     
    },    
    _onMediaEnded: function(sender, eventArgs) {
		sender.position = 0;
	  	sender.stop();
    },
    _onMediaFailed: function(sender, eventArgs) {
        alert(String.format( Ee.UI.Xaml.Media.Res.mediaFailed, this._player.get_mediaUrl() ) );
    },
    _playNextVideo: function() { 
        var cVideos = 1;
        if (this._currentMediainfo<cVideos)
            this._player.set_mediainfo( get_mediainfo( this._currentMediainfo ) );  
        
        if(this._player.mhm_noautoplay==1 && this._player.get_autoPlay().toString()=="false")
            this._player.set_autoPlay(true);  
        this._player.mhm_noautoplay=1;
    }        
}
