﻿///////////////////////////////////////////////////////////////////////////////
//
//  Startplayer.js   			version 1.0
//
//  This file is provided by Microsoft as a helper file for websites that
//  incorporate Silverlight Objects. This file is provided under the Silverlight 
//  SDK 1.0 license available at http://go.microsoft.com/fwlink/?linkid=94240.  
//  You may not use or distribute this file or the code in this file except as 
//  expressly permitted under that license.
// 
//  Copyright (c) 2007 Microsoft Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////




function StartWithParent(parentId, appId) {
    new StartPlayer_0(parentId);
}

function StartPlayer_0(param) {

	var xamlSource;
	if (param == 'standalone')
		xamlSource = 'XAML/standaloneplayer.xaml';
	else
		xamlSource = 'XAML/player.xaml';
    
    this._hostname = EePlayer.Player._getUniqueName("xamlHost");
    Silverlight.createObjectEx( {   source: xamlSource, 
                                        parentElement: $get("divPlayer_0"), 
                                        id:this._hostname, 
                                        properties:{ width:'735px', height:'650px', 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(sender, eventArgs)
	{

		this._player = $create(ExtendedPlayer.Player,
                                  { // properties
                                  	autoPlay: true,
                                  	volume: 1.0,
                                  	muted: false
                                  },
                                  { // event handlers
                                  	//mediaEnded: Function.createDelegate(this, this._onMediaEnded),
                                  	mediaFailed: Function.createDelegate(this, this._onMediaFailed)
                                  },
                                  null, $get(this._hostname));


		//wires up actions to take in response to entering or exiting a full screen video event.
		sender.Content.onFullScreenChange = onFullScreenChanged;
		buildImages(sender);
	},

	_onMediaFailed: function(sender, eventArgs)
	{
		alert(String.format(Ee.UI.Xaml.Media.Res.mediaFailed, this._player.get_mediaUrl()));
	}
}
