

<?php
	/**
	 * Plugin Name: Spacial Shortcodes
	 * Plugin URI: http://www.spacial.com/spacial-shortcodes
	 * Description: Custom Shortcodes for Spacial Website
	 * Version: 1.0
	 * Author: Spacial Audio
	 * Author URI: http://www.spacial.com
	 */     
//shortcode
add_shortcode('spacial_players', 'spacial_players_shortcode');

/**
 * Renders [spacial_players] shortcode
 */
function spacial_players_shortcode() {

	if (isset($_GET["pls_data"]) || isset($_GET["asx_data"])) {
		$fileName = isset($_GET['pls_data']) ? 'listen.pls' : 'station.asx';
		wp_enqueue_script("syntax_highlighter", "http://media.audiorealm.com/", array('jquery'));
		ob_clean();
		header('Pragma: public');
		header("Content-type: text/plain");
		header('Content-Disposition: attachment; filename="' . $fileName . '"');
		echo stripslashes($_GET["pls_data"]);
		echo stripslashes($_GET["asx_data"]);
		die();
	}
	
	ob_start();
	?>
	<style>
		#CheapestStream
		{
			position: relative !important;
			left:0px !important;
			top:0px;
			width:300px;
			height:270px;
			display:block;
		}
		
		#player_wrapper{
			position: absolute !important;
		}
	</style>
	<div style="padding-top: 10px;">
		<?php
		$url = urldecode($_GET["url"]);
		$server_type = $_GET["servertype"];
		$mime_type = $_GET["mimetype"];

		switch ($server_type) {
			case "SamBroadcasterCloud":
				echo renderSamBroadcasterCloud($url);
				break;
			case "stw":
				echo renderStwFlashPlayer($url);
				break;
			case "shoutcastv1":
				echo renderShoutcast($url, $mime_type, 1);
				break;
			case "shoutcastv2":
				echo renderShoutcast($url, $mime_type, 2);
				break;
			case "icecastv1":
				echo renderIcecast($url);
				break;
			case "icecastv2":
				echo renderIcecast($url);
				break;
			case "wms-pull":
				echo renderWmsPushOrPull($url, $mime_type, $server_type, false);
				break;
			case "wms-push":
				echo renderWmsPushOrPull($url, $mime_type, $server_type, true);
				break;
			case "live365":
				echo renderLiveThreeSixFive();
				break;
			default:
				echo renderUnknown();
				break;
		}
		?>
	</div>
	<?php
	return ob_get_clean();
}

function renderSamBroadcasterCloud($url) {
        $url_query_parts = array();
        $url_string = parse_url($url, PHP_URL_QUERY);
        parse_str($url_string, $url_query_parts);
        $sid = $url_query_parts['sid'];
        $new_url = str_replace("{0}", $sid, "http://listen.samcloud.com/v2/{0}");
	ob_start();
	?>
	<div class="row">
		<div class="col-12 text-center" style="text-align: center">
			<h3>Listen to your SAM Broadcaster Cloud Station</h3>
			<p>1. Open the following url: <a href="<?php echo esc_html($new_url) ?>" target="_blank"><?php echo esc_html($new_url) ?></a></p>
			<h3>OR</h3>
		</div>
	</div>
	<div class="row">
		<div class="col-12" style="text-align: center">
			<p>
				2. Open the following URL with any of the following popular media players: <br />
				<?php echo esc_html($url) ?>
			</p>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<br>
			<h1 style="text-align:center">Popular Media Players</h1>
		</div>
	</div>
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://www.videolan.org/vlc/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_vlcplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">VLC Player</h3>
										<p class="box-content-height elementor-image-box-description">VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs, and various streaming protocols.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://www.videolan.org/vlc/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://mpc-hc.org/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_mpc.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Media Player Classic</h3>
										<p class="box-content-height elementor-image-box-description">MPC-HC is an extremely light-weight, open source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://mpc-hc.org/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://windows_media_player.en.downloadastro.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_windowsmediaplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Windows Media Player</h3>
										<p class="box-content-height elementor-image-box-description">Windows Media Player was created by music and film lovers, and especially those who love to combine the two mediums. It was designed to be the perfect comprehensive tool for playing music and video files on your computer.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://windows_media_player.en.downloadastro.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<br />
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://kmplayer.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_kmplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">KM Player</h3>
										<p class="box-content-height elementor-image-box-description">Plays ultra high definition perfectly. You can enjoy high quality images such as 4K, 8K, UHD, and 60FPS.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://kmplayer.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://potplayer.daum.net/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_pot.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">POT Player</h3>
										<p class="box-content-height elementor-image-box-description">MPC-HC is an extremely light-weight, open source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://potplayer.daum.net/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://www.winamp.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_winamp.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Winamp</h3>
										<p class="box-content-height elementor-image-box-description">A leaked version of Winamp 5.8 recently spread over the Internet. Consequently, we have decided to make this new version available to you, revised by us.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://www.winamp.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<?php
	return ob_get_clean();
}

function renderShoutcast($url, $mime_type, $version) {
	ob_start();
	$url = rtrim($url, '/').'/';
	$url_exploded_parts = explode("/", $url);
	$url_parsed_parts = parse_url($url);

	if ($version == 2) {
		$listen_url = "http://" . $url_parsed_parts["host"] . "/" . "listen.pls?sid=" . $url_exploded_parts[count($url_exploded_parts)-2];
	} else {
		$listen_url = $url . "listen.pls";
	}

	if ($version == 2 && $mime_type == "audio/mpeg") {
	?>
		<script language="JavaScript" type="text/javascript">
		    var wrapper;
		    var jsReady = false;
		    var controlsShown = false;

		    var readyStateCheckInterval = setInterval(function() {
			if (document.readyState === "complete") {
			    clearInterval(readyStateCheckInterval);
				    if(navigator.appName.indexOf("Microsoft") != -1) {
					    wrapper = window.simpleplayer;
				    }else {
					    wrapper = window.document.simpleplayer;
				    }
				    setTimeout(function() {doStartPlayer();},2000);
			}
		    }, 10);

		    function doStartPlayer() {
			    wrapper.Open('<?php echo $url; ?>', true, null);
			    wrapper.showControls(1);
			    wrapper.Start();
		    }
		</script>
		
		<br/><h3>ShoutCast 2 Flash Player</h3> <br />
		
		<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="50" id="simpleplayer" align="middle">
		    <param name="allowScriptAccess" value="always" />
		    <param name="allowFullScreen" value="true" />
		    <param name="movie" value="http://media.audiorealm.com/simpleplayer/simpleplayer.swf?playerid=<?php echo time(); ?>" />
		    <param name="quality" value="high" />
		    <param name="bgcolor" value="#000000" />
		    <embed src="http://media.audiorealm.com/simpleplayer/simpleplayer.swf" quality="high" bgcolor="#000000" width="320" height="50" name="simpleplayer" align="middle" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
		</object><br/><br/>
		
		
	<?php
	}
	?>


	<div class="row">
		<div class="col-12">
			<h1 style="text-align:center">
				Listen to your SHOUTCast Station
			</h1>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<p style="text-align:center">
				Download the listen.pls file <a href="<?php echo $listen_url ?>"><?php echo $listen_url ?></a> <br /><br/>
				Open the downloaded file with any of the following popular media players
			</p>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<br>
			<h1 style="text-align:center">Popular Media Players</h1>
		</div>
	</div>
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://www.videolan.org/vlc/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_vlcplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">VLC Player</h3>
										<p class="box-content-height elementor-image-box-description">VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs, and various streaming protocols.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://www.videolan.org/vlc/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://mpc-hc.org/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_mpc.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Media Player Classic</h3>
										<p class="box-content-height elementor-image-box-description">MPC-HC is an extremely light-weight, open source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://mpc-hc.org/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://windows_media_player.en.downloadastro.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_windowsmediaplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Windows Media Player</h3>
										<p class="box-content-height elementor-image-box-description">Windows Media Player was created by music and film lovers, and especially those who love to combine the two mediums. It was designed to be the perfect comprehensive tool for playing music and video files on your computer.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://windows_media_player.en.downloadastro.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<br />
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://kmplayer.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_kmplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">KM Player</h3>
										<p class="box-content-height elementor-image-box-description">Plays ultra high definition perfectly. You can enjoy high quality images such as 4K, 8K, UHD, and 60FPS.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://kmplayer.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://potplayer.daum.net/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_pot.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">POT Player</h3>
										<p class="box-content-height elementor-image-box-description">MPC-HC is an extremely light-weight, open source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://potplayer.daum.net/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://www.winamp.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_winamp.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Winamp</h3>
										<p class="box-content-height elementor-image-box-description">A leaked version of Winamp 5.8 recently spread over the Internet. Consequently, we have decided to make this new version available to you, revised by us.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://www.winamp.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php
	return ob_get_clean();
}

function renderIcecast($url) {
	$pls = "[playlist]
			NumberOfEntries=1
			File1=" . $url;

	ob_start();
	?>

	<div class="row">
		<div class="col-12">
			<h1 style="text-align:center">
				Listen to your IceCast Station
			</h1>
		</div>
	</div>
	<div class="row">
		<div style="text-align:center" class="col-12">
			<ol style="list-style: none">
				<li>Copy the following url: <a href="<?php echo esc_html($url) ?>"><?php echo esc_html($url) ?></a></li>
				<li>Open the URL with any of the following popular media players</li>
			</ol>
		</div>
	</div>
	<div class="row">
		<div style="text-align:center" class="col-12">
			<h1>OR</h1>
		</div>
	</div>
	<div class="row">
		<div style="text-align:center" class="col-12">
			<form id="download_pls">
				<input type="hidden" name="url" id="url" value="<?php echo $_GET["url"] ?>" />
				<input type="hidden" name="servertype" value="<?php echo $_GET["servertype"]; ?>" />
				<input type="hidden" name="mimetype" value="<?php echo $_GET["mimetype"]; ?>" />
				<input type="hidden" name="pls_data" value="<?php echo esc_html($pls) ?>" />
			</form>
			<ol style="list-style: none">
				<li>Click <a style="cursor: pointer"  href="#" onclick="jQuery('#download_pls').submit()">here</a> to download the .pls file</li>
				<li>Open the downloaded file with any of the following popular media players</li>
			</ol>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<br>
			<h1 style="text-align:center">Popular Media Players</h1>
		</div>
	</div>
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://www.videolan.org/vlc/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_vlcplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">VLC Player</h3>
										<p class="box-content-height elementor-image-box-description">VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs, and various streaming protocols.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://www.videolan.org/vlc/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://mpc-hc.org/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_mpc.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Media Player Classic</h3>
										<p class="box-content-height elementor-image-box-description">MPC-HC is an extremely light-weight, open source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://mpc-hc.org/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="https://windows_media_player.en.downloadastro.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_windowsmediaplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Windows Media Player</h3>
										<p class="box-content-height elementor-image-box-description">Windows Media Player was created by music and film lovers, and especially those who love to combine the two mediums. It was designed to be the perfect comprehensive tool for playing music and video files on your computer.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="https://windows_media_player.en.downloadastro.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<br />
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://kmplayer.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_kmplayer.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">KM Player</h3>
										<p class="box-content-height elementor-image-box-description">Plays ultra high definition perfectly. You can enjoy high quality images such as 4K, 8K, UHD, and 60FPS.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://kmplayer.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://potplayer.daum.net/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_pot.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">POT Player</h3>
										<p class="box-content-height elementor-image-box-description">MPC-HC is an extremely light-weight, open source media player for Windows®. It supports all common video and audio file formats available for playback. We are 100% spyware free, there are no advertisements or toolbars.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://potplayer.daum.net/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<div class="elementor-image-box-wrapper">
									<figure class="elementor-image-box-img"><a href="http://www.winamp.com/" target="_blank"><img width="100" height="100"
											src="https://spacial.com/wp-content/uploads/2019/09/listen_winamp.jpg"
											class="attachment-full size-full" alt=""></a></figure>
									<div class="elementor-image-box-content">
										<h3 class="elementor-image-box-title">Winamp</h3>
										<p class="box-content-height elementor-image-box-description">A leaked version of Winamp 5.8 recently spread over the Internet. Consequently, we have decided to make this new version available to you, revised by us.</p>
										<div class="elementor-button-wrapper">
											<br />
											<a href="http://www.winamp.com/" class="listenPageBtn elementor-button-link elementor-button elementor-size-md elementor-animation-hang" role="button">
												<span class="elementor-button-content-wrapper">
													<span class="elementor-button-text">DOWNLOAD NOW</span>
												</span>
											</a>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


	<?php
	return ob_get_clean();
}

function renderWmsPushOrPull($url, $mime_type, $server_type, $push) {
	ob_start();

	if ($push) {
		$wmsUrl = str_replace("http", "mms", $url);
	} else {
		$wmsUrl = $url; //substr($url, 0, strrpos($url, "/"));
		$showWmWarning = true;
	}

	$asx = '<ASX VERSION="3.0">
						<TITLE>MyStationName</TITLE>
						<COPYRIGHT>MyStation 2012</COPYRIGHT>
						<ABSTRACT>MyStationDescription</ABSTRACT>
						<ENTRY>
							<TITLE>MyStation Live</TITLE>
							<REF HREF="'.$wmsUrl.'" />
							<AUTHOR>MyStationName</AUTHOR>
						</ENTRY>
					</ASX>';
	?>
	<form id="download_asx">
		<input type="hidden" name="url" id="url" value="<?php echo $url ?>" />
		<input type="hidden" name="servertype" value="<?php echo $server_type ?>" />
		<input type="hidden" name="mimetype" value="<?php echo $mime_type ?>" />
		<input type="hidden" name="asx_data" value="<?php echo esc_html($asx) ?>" />

	</form>
	<?php
	if ($mime_type != "audio/mpeg") {
		?>
		<div class="row">
			<div class="col-12">
				<h1 style="text-align:center">Listen to your Windows Media Station</h1>
			</div>
		</div>
		<div class="row">
			<div class="col-12">
				<p style="text-align:center">
					Click <a style="cursor: pointer"  href="#" onclick="jQuery('#download_asx').submit()">here</a> to download a file which you can use to play your station in Windows Media Player.
				</p>
			</div>
		</div>
		<div class="row">
			<div class="col-12">
				<p style="text-align:center">
					Alternatively, copy and paste the code below into a text file and save it with a .asx file extention.
				</p>
			</div>
		</div>
		<div class="row">
			<div class="col-12">
			<?php if($showWmWarning) { ?>
				<p style="text-align:center">
					<b>Please note, this .asx file will only work if opened from your local machine where SAM is running as it connects directly to your SAM encoder.</b>
				</p>
			<?php } ?>
			</div>
		</div>
		<div class="row">
			<div class="col-12">
				<pre class="code language-html">
					<?php echo esc_html($asx); ?>
				</pre>
			</div>
		</div>
		<?php
	}

	return ob_get_clean();
}

function renderLiveThreeSixFive() {
	ob_start();
	?>
	<div class="row">
		<div class="col-12">
			<h1 style="text-align:center">Live365 Station</h1>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<p style="text-align:center">
				Click <a href="http://www.live365.com/index.live" target="_blank">here</a> to search for your station on Live365
			</p>
		</div>
	</div>

	<?php
	return ob_get_clean();
}

function renderStwFlashPlayer($url) {
	ob_start();
        $url_parts = explode("/", $url);
        $mount = array_pop($url_parts);
        $environment = get_option('spacial_api_environment');
        
        $service_url = "https://samcloud.spacial.com/api/listen/retrieveStationIdWithCallsign?callsign=$mount&format=json";
        $tmp = @file_get_contents($service_url);
        $decode = json_decode($tmp);
        $playerUrl = "samcloudmedia.spacial.com/webwidgets/player/v4/index.html?src=cs&sid=$decode->StationId&token=$decode->Token";        
	?>

	<div class="row">
		<div class="col-12">
			<h1 style="text-align:center">
			CheapestStream Media Player
			</h1>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<p style="text-align:center">
				If you want to send the direct link to your friends and family you can do so by using the following link: <br /><br/>
				<a href="http://<?php echo $playerUrl; ?>&startstation=true" target="_blank">http://<?php echo $playerUrl; ?>&startstation=true</a> <br /><br />
				For more listen link options please visit the CheapestStream client zone: <br /><a href="http://userzone.spacial.com" target="_blank">http://userzone.spacial.com</a> <br />
			</p>
		</div>
	</div>
	<div class="elementor-container elementor-column-gap-default">
		<div class="elementor-row">
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<br />
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container elementor-position-middle" style="margin-left: 6%;">
								<iframe align="right" id="innerFramePlayer" title="Flash Player" src="https://<?php echo $playerUrl?>" width="350" height="210" scrolling="no" frameborder="0" allowtransparency="true"  title="The iframe flash player display.">
									<p>Your browser does not support iframes. <a id="playerLink" href="http://<?php echo $playerUrl?>">View the content of this inline frame</a> with your browser</p>
								</iframe>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="elementor-element elementor-column elementor-col-33 elementor-top-column"
				data-element_type="column">
				<div class="elementor-column-wrap  elementor-element-populated">
					<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-position-top elementor-vertical-align-top elementor-widget elementor-widget-image-box"
							data-element_type="widget" data-widget_type="image-box.default">
							<div class="elementor-widget-container">
								<br />
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php
	return ob_get_clean();
}

function renderUnknown() {
    ob_start();
    ?>
    <br/><h3>Unknown Server Type</h3>
    <p>
	Unfortunately we were not able to detect your station type and we are unable to provide you with more information. <br /><br/>
	Please "right-click" on your encoder and click on "Listen To Stream".
    </p>

    <?php
    return ob_get_clean();
}
