﻿/* Do not remove this commented code. This is compiled by Expression Media Encoder at template compile time.

 
*/

function StartPlayer_0(parentId) {
    try {
    	eval('background:document.body.style.backgroundColor="#ck"');
    } catch(e){}

    this._hostname = ExpressionPlayer.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:document.body.style.backgroundColor, isWindowless:'false', inplaceInstallPrompt:true }, 
                                    events:{ onLoad:Function.createDelegate(this, this._handleLoad) } } );
    this._currentMediainfo = 0;     
}
StartPlayer_0.prototype= {
    _handleLoad: function() {
        this._player = $create(   ExtendedPlayer.Player, 
                                  { // properties
                                    autoPlay       : this.autoPlayParam(), 
                                    autoCue        : this.autoCueParam(),
				                    scaleMode 	   : this.scaleModeParam(),
                                    muted          : this.mutedParam(),
				                    enableCaptions : this.enableCaptionsParam(),
                                    volume         : 1.0
                                  }, 
                                  { // event handlers
                                    mediaEnded: Function.createDelegate(this, this._onMediaEnded),
                                    mediaFailed: Function.createDelegate(this, this._onMediaFailed)
                                  },
                                  null, $get(this._hostname)  );   

	this._playlist=[];
	var strCode = 	'this._playlist=[{ "mediaSource": "http://mediaserver02.cybernet.be/spaliveresult","placeholderImageSource": "","chapters": [] }  ];';
        try {
            eval( strCode ); 
            }
        catch(e){}



	var galleryItems=[];
	var strCode = 	'galleryItems=[];';
        try {
            eval( strCode ); 
            }
        catch(e){}

        this._player.set_galleryInfo( galleryItems, Function.createDelegate(this, this._onClickGalleryItem) );  

	this._playNextVideo();                                      
    },
    
    _onClickGalleryItem : function (galleryItemIndex) {
        this._player.set_mediainfo( this._playlist[ galleryItemIndex ] ); 
        this._currentMediainfo = galleryItemIndex+1;
    },

    _onMediaEnded: function(sender, eventArgs) {
        window.setTimeout( Function.createDelegate(this, this._playNextVideo), 1000);
    },
    
    _onMediaFailed: function(sender, eventArgs) {
        alert(String.format( Sys.UI.Silverlight.MediaPlayer.Res.mediaFailed, this._player.get_mediaSource() ) );
    },
       
    _playNextVideo: function() {
        if (this._playlist!=null) {
            if (this._currentMediainfo<this._playlist.length)
                this._player.set_mediainfo( this._playlist[ this._currentMediainfo++ ] );    
        }
    },
    
    autoCueParam: function() {
	    var autoCue=true;
	    try {
		    eval("autoCue=('True'!=='False')");
	    } catch(e){}
	    return autoCue;
    },  
    
    autoPlayParam: function() {
	    var autoPlay=true;
	    try
	    {
		    eval("autoPlay=('True'!=='False')");
	    } catch(e){}
	    return autoPlay;
    },  
    
    scaleModeParam: function() {
	    var scaleMode = 1/*Normal*/;
	    try {
		    eval("scaleMode=1;");
	    } catch(e){}
	    return scaleMode;
    },

    enableCaptionsParam: function() {
	    var enableCaptions=true;
	    try {
		    eval("enableCaptions=('True'!=='False');");
	    } catch(e){}
	    return enableCaptions;
    },

    mutedParam: function() {
	    var muted=false;
	    try {
		    eval("muted=('False'!=='False');");
	    } catch(e){}
	    return muted;
    }
}
function StartWithParent(parentId, appId) {
    new StartPlayer_0(parentId);
}

