﻿/* Functions loading and initializing both audio and video flash players */
/* Added: 17/03/2011 */
/* Author: Jerzy Plutowicz */ 

function LoadAudioPlayer(playerId, productId, serverUrl, playerKey, clipName, encryptedData, culture, siteName, isSample) {
	$f(playerId, serverUrl + '/swfs/smdplayer.swf', {
		wmode: 'transparent',
		key:  playerKey,
		contextMenu: ['Sheet Music Direct Player 1.8.0', 'Mode: A2', 'Compression: Off', 'PID: ' + productId ],
		onError: function(errorCode, errorMessage) { $('#audioPlayer_comments').text(errorMessage); },
		clip:{
			url: 'http://www.sheetmusicdirect.com/satellite/3/' + encryptedData + '/' + productId + '/' + culture + '/' + siteName + '/' + isSample + '/GetStream/file.mp3',
			autoPlay: false,
			autoBuffering: true,
			onBeforeBegin: function() { $f('player').close(); },
			onStart: function(clip) { pageTracker._trackEvent('Flash Audio [' + clipName + ']', 'Play', clip.url); },
			onStop: function(clip) { pageTracker._trackEvent('Flash Audio [' + clipName + ']', 'Stop', clip.url); }
		},
		plugins: {
			controls: {
				url: serverUrl + '/swfs/smdplayer.controls-tube-3.1.3.swf',
				fullscreen: false,
				height: 20
			},
			audio: { url: serverUrl + '/swfs/smdplayer.audio.swf' }
		}
	});
};

function LoadVideoPlayer(playerId, productId, serverUrl, playerKey, clipName, encryptedData, culture, siteName, isSample) {

	$f(playerId, { src: serverUrl + '/swfs/smdplayer.swf', wmode: 'opaque'}, {
		key: playerKey,
		logo: {
			url: 'http://www.sheetmusicdirect.com/images/3p/fp/player.logo.png',
			fullscreenOnly: true
		},
		contextMenu: ['Sheet Music Direct Player 1.8.0', 'Mode: V1', 'Compression: Off','PID: ' + productId ],
		play: {
			url: 'http://www.sheetmusicdirect.com/images/3p/fp/player.play.png',
			width: 83,
			height: 83
		},
		onError: function(errorCode, errorMessage){ $('#videoPlayer_comments').text(errorMessage); },
		canvas: { backgroundColor: '#000000', backgroundGradient: 'none' },
		plugins: {
			controls: {
				url: serverUrl + '/swfs/smdplayer.controls-tube-3.1.3.swf',
				fullscreen: false,
				height: 20
			}
		}
	});

	// add splash screen if sample
	if (isSample == '1') {
		$f(playerId).play([
			{ url: 'http://musicroom.com/images/Ads/logo2008_gb.gif', duration: 2, scaling: 'orig' },
			{ 
				url: 'http://www.sheetmusicdirect.com/satellite/3/' + encryptedData + '/' + productId + '/' + culture + '/' + siteName + '/' + isSample + '/GetStream/file.flv', 
				autoPlay: false, 
				autoBuffering: true, 
				scaling: 'fit', 
				onBegin: function(clip) { this.getScreen().animate({ width: clip.w, height: clip.h }, 100); },
				onStart: function(clip) { pageTracker._trackEvent('Flash Video [' + clipName + ']', 'Play', clip.url); },
				onStop: function(clip) { pageTracker._trackEvent('Flash Video [' + clipName + ']', 'Stop', clip.url); }
			}
		]);
	}
	else{
		$f(playerId).play([
			{
				url: 'http://www.sheetmusicdirect.com/satellite/3/' + encryptedData + '/' + productId + '/' + culture + '/' + siteName + '/' + isSample + '/GetStream/file.flv',
				autoPlay: false,
				autoBuffering: true,
				scaling: 'fit',
				onBegin: function(clip) { this.getScreen().animate({ width: clip.w, height: clip.h }, 100); },
				onStart: function(clip) { pageTracker._trackEvent('Flash Video [' + clipName + ']', 'Play', clip.url); },
				onStop: function(clip) { pageTracker._trackEvent('Flash Video [' + clipName + ']', 'Stop', clip.url); }
			}
		]);
	};
};
