<commit_before><?php
/**
 * $Id$
 *
 * Video handling helper functions
 *
 * @author <NAME>, 2007-2008 <<EMAIL>>
 */

/**
 * Embeds a video in a html page using Windows Media Player
 *
 * All parameters are documented here:
 * http://www.mioplanet.com/rsc/embed_mediaplayer.htm
 *
 * Common parameters:
 *	AutoStart	true/false
 *	uiMode		invisible, none, mini, full
 *	fullScreen	true/false
 *	PlayCount	numeric
 *
 * Windows Media Player 6.4: "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
 *
 * @param $url video url to embed
 * @param $w width of player window (not width of video clip)
 * @param $h height of player window (not height of video clip)
 * @return html code
 */
function embedVideo($url, $w = 352, $h = 288, $params = array())
{
	global $h;
	if (!is_numeric($w) || !is_numeric($h)) return false;

	if (strpos($h->session->user_agent, 'MSIE')) {
		//Tested in IE 7
		//FIXME try IE 6
		$data  = '<object type="application/x-oleobject'.
				' width="'.$w.'" height="'.$h.'"'.
				' classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6">';	//Windows Media Player 7, 9, 10 and 11
		$data .= '<param name="URL" value="'.$url.'">';
		if (empty($params)) {
			//default settings
			$data .= '<param name="AutoStart" value="false">';
			$data .= '<param name="uiMode" value="mini">';
		} else {
			foreach ($params as $name => $val) {
				$data .= '<param name="'.$name.'" value="'.$val.'">';
			}
		}
		$data .= '</object>';
	} else {
		//This works with Firefox in Windows and Linux and Opera in Windows
		//For Firefox Linux, install mozilla-plugin-vlc
		//For Firefox Windows, install wmpfirefoxplugin.exe from http://port25.technet.com
		$data = '<embed type="application/x-mplayer2"'.
				' width="'.$w.'" height="'.$h.'"'.
				' src="'.$url.'"'.
				' ShowControls="1" ShowStatusBar="1"'.
				' autostart="'.(!empty($params['AutoStart']) && $params['AutoStart'] == 'true' ? '1' : '0').'">';
		$data .= '</embed>';
	}

	return $data;
}

/**
 * XXX
 */
function embedAudio($url, $w = 352)
{
	global $h;
	if (!is_numeric($w)) return false;

	if (strpos($h->session->user_agent, 'MSIE')) {
		$h = 46;
		//Tested in IE 7
		//FIXME try IE 6
		$data  = '<object type="application/x-oleobject'.
				' width="'.$w.'" height="'.$h.'"'.
				' classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6">';	//Windows Media Player 7, 9, 10 and 11
		$data .= '<param name="URL" value="'.$url.'">';

		//default settings
		$data .= '<param name="AutoStart" value="false">';
		$data .= '<param name="uiMode" value="mini">';
		$data .= '</object>';
	} else {
		$h = 50;
		//This works with Firefox in Windows and Linux and Opera in Windows
		//For Firefox Linux, install mozilla-plugin-vlc
		//For Firefox Windows, install wmpfirefoxplugin.exe from http://port25.technet.com
		$data = '<embed type="application/x-mplayer2"'.
				' width="'.$w.'" height="'.$h.'"'.
				' src="'.$url.'"'.
				' ShowControls="1" ShowStatusBar="1"'.
				' autostart="0">';
		$data .= '</embed>';
	}

	return $data;
}



/**
 * Helper function for embedding quicktime video
 * Requires Apple's AC_QuickTime.js from http://developer.apple.com/internet/ieembedprep.html
 * Parameter docs: http://www.apple.com/quicktime/tutorials/embed2.html
 *
 * @param $url url to embed<commit_msg>functions_video.php: fixed up parameter naming ($h (height) shadowed $h (handler))<commit_after><?php
/**
 * $Id$
 *
 * Video handling helper functions
 *
 * @author <NAME>, 2007-2009 <<EMAIL>>
 */

/**
 * Embeds a video in a html page using Windows Media Player
 *
 * All parameters are documented here:
 * http://www.mioplanet.com/rsc/embed_mediaplayer.htm
 *
 * Common parameters:
 *	AutoStart	true/false
 *	uiMode		invisible, none, mini, full
 *	fullScreen	true/false
 *	PlayCount	numeric
 *
 * Windows Media Player 6.4: "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
 *
 * @param $url video url to embed
 * @param $w width of player window (not width of video clip)
 * @param $h height of player window (not height of video clip)
 * @return html code
 */
function embedVideo($url, $width = 352, $height = 288, $params = array())
{
	if (!is_numeric($width) || !is_numeric($height)) return false;

	if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) {
		//Tested in IE 7
		//FIXME try IE 6
		$data  = '<object type="application/x-oleobject'.
				' width="'.$width.'" height="'.$height.'"'.
				' classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6">';	//Windows Media Player 7, 9, 10 and 11
		$data .= '<param name="URL" value="'.$url.'">';
		if (empty($params)) {
			//default settings
			$data .= '<param name="AutoStart" value="false">';
			$data .= '<param name="uiMode" value="mini">';
		} else {
			foreach ($params as $name => $val) {
				$data .= '<param name="'.$name.'" value="'.$val.'">';
			}
		}
		$data .= '</object>';
	} else {
		//This works with Firefox in Windows and Linux and Opera in Windows
		//For Firefox Linux, install mozilla-plugin-vlc
		//For Firefox Windows, install wmpfirefoxplugin.exe from http://port25.technet.com
		$data = '<embed type="application/x-mplayer2"'.
				' width="'.$width.'" height="'.$height.'"'.
				' src="'.$url.'"'.
				' ShowControls="1" ShowStatusBar="1"'.
				' autostart="'.(!empty($params['AutoStart']) && $params['AutoStart'] == 'true' ? '1' : '0').'">';
		$data .= '</embed>';
	}

	return $data;
}

/**
 * XXX
 */
function embedAudio($url, $width = 352)
{
	if (!is_numeric($w)) return false;

	if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) {
		$height = 46;
		//Tested in IE 7
		//FIXME try IE 6
		$data  = '<object type="application/x-oleobject'.
				' width="'.$width.'" height="'.$height.'"'.
				' classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6">';	//Windows Media Player 7, 9, 10 and 11
		$data .= '<param name="URL" value="'.$url.'">';

		//default settings
		$data .= '<param name="AutoStart" value="false">';
		$data .= '<param name="uiMode" value="mini">';
		$data .= '</object>';
	} else {
		$height = 50;
		//This works with Firefox in Windows and Linux and Opera in Windows
		//For Firefox Linux, install mozilla-plugin-vlc
		//For Firefox Windows, install wmpfirefoxplugin.exe from http://port25.technet.com
		$data = '<embed type="application/x-mplayer2"'.
				' width="'.$width.'" height="'.$height.'"'.
				' src="'.$url.'"'.
				' ShowControls="1" ShowStatusBar="1"'.
				' autostart="0">';
		$data .= '</embed>';
	}

	return $data;
}



/**
 * Helper function for embedding quicktime video
 * Requires Apple's AC_QuickTime.js from http://developer.apple.com/internet/ieembedprep.html
 * Parameter docs: http://www.apple.com/quicktime/tutorials/embed2.html
 *
 * @param $url url to embed
{'fraction_non_alphanumeric': 0.20074682598954444, 'fraction_numerical': 0.03495145631067961, 'mean_word_length': 3.602061855670103, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2210497', 'n_tokens_mistral': 2673, 'n_tokens_neox': 2349, 'n_words': 602}