4 all file checks and conditions should be checked prior to loading this page.
5 this page serves as a wrapper for the cortado java applet
7 @@this may be depreciated in favor of a central hosted java applet
12 function cortado_iframe() {
13 if(!function_exists('filter_input')){
14 die('your version of php lacks <b>filter_input()</b> function</br>');
17 // set the parent domain if provided
18 $parent_domain = isset( $_GET['parent_domain'] ) ?
$_GET['parent_domain'] : false;
20 //default to null media in not provided:
21 $media_url = isset( $_GET['media_url'] ) ?
$_GET['media_url'] : false;
22 if( strval($media_url) === ''){
23 error_out('not valid or missing media url');
25 //default duration to 30 seconds if not provided. (ideally cortado would read this from the video file)
26 //$duration = (isset($_GET['duration']))?$_GET['duration']:0;
27 $duration = filter_input(INPUT_GET
, 'duration', FILTER_SANITIZE_NUMBER_INT
);
28 if( is_null($duration) ||
$duration===false){
32 //id (set to random if none provided)
33 //$id = (isset($_GET['id']))?$_GET['id']:'vid_'.rand('10000000');
34 $id = isset($_GET['id']) ?
$_GET['id'] : false;
35 if( is_null($id) ||
$id===false){
36 $id = 'vid_'.rand(0,10000000);
39 $width = filter_input(INPUT_GET
, 'width', FILTER_SANITIZE_NUMBER_INT
);
40 if( is_null($width) ||
$width===false){
43 $height = filter_input(INPUT_GET
, 'height', FILTER_SANITIZE_NUMBER_INT
);
45 $stream_type = (isset($_GET['stream_type']))?
$_GET['stream_type']:'video';
46 if($stream_type=='video'){
48 if(is_null($height) ||
$height===false)
50 } else { // if($stream_type=='audio')
53 if(is_null($height) ||
$height===false)
57 //everything good output page:
60 'media_url' => $media_url,
63 'duration' => $duration,
66 'parent_domain' => $parent_domain
71 * JS escape function copied from MediaWiki's Xml::escapeJsString()
73 function escapeJsString( $string ) {
74 // See ECMA 262 section 7.8.4 for string literal format
82 # To avoid closing the element or CDATA section
86 # To avoid any complaints about bad entity refs
89 # Work around https://bugzilla.mozilla.org/show_bug.cgi?id=274152
90 # Encode certain Unicode formatting chars so affected
91 # versions of Gecko don't misinterpret our strings;
92 # this is a common problem with Farsi text.
93 "\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER
94 "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
96 return strtr( $string, $pairs );
99 function error_out($error=''){
100 output_page(array('error' => $error));
103 function output_page($params){
105 ?
><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
106 <html xmlns
="http://www.w3.org/1999/xhtml">
108 <meta http
-equiv
="Content-Type" content
="text/html; charset=iso-8859-1" />
109 <title
>cortado_embed
</title
>
110 <script type
="text/javascript">
111 <?
//set the parent domain:
112 if( $parent_domain ){?
>
114 document
.domain
= '<?php echo htmlspecialchars( $parent_domain )?>';
117 console
.log('could not set domain to <?php echo htmlspecialchars( $parent_domain )?>');
122 function setGlobalJplayer(){
123 jPlayer
= document
.getElementById('<?php echo htmlspecialchars( $id ) ?>');
126 <style type
="text/css">
136 <body onload
="setGlobalJplayer()" >
138 $appid = ( preg_match("/MSIE/i", getenv("HTTP_USER_AGENT")) ) ?
'' : 'classid="java:com.fluendo.player.Cortado.class"';
139 if (empty($error)){ ?
>
140 <div id
="jPlayer"></div
>
141 <OBJECT id
="<?php echo htmlspecialchars( $id ) ?>"
142 code
="com.fluendo.player.Cortado.class"
144 archive
="binPlayers/cortado/cortado-wmf-r46643.jar"
145 width
="<?php echo htmlspecialchars( $width )?>"
146 height
="<?php echo htmlspecialchars( $height )?>" >
147 <param name
="url" value
="<?php echo htmlspecialchars( $media_url )?>" />
148 <param name
="local" value
="false"/>
149 <param name
="keepaspect" value
="true" />
150 <param name
="video" value
="<?php echo htmlspecialchars( $video )?>" />
151 <param name
="audio" value
="<?php echo htmlspecialchars( $audio )?>" />
152 <param name
="seekable" value
="false" />
155 <param name
="duration" value
="<?php echo htmlspecialchars( $duration )?>" />
158 <param name
="showStatus" value
="hide" />
159 <param name
="autoPlay" value
="true" />
160 <param name
="BufferSize" value
="8192" />
161 <param name
="BufferHigh" value
="30" />
162 <param name
="BufferLow" value
="5" />
165 <b
>Error
:</b
> <?php
echo htmlspecialchars( $error )?
>
174 javascript envoked version:
176 jPlayer = document.createElement('OBJECT');
177 jPlayer.setAttribute('classid', 'java:com.fluendo.player.Cortado.class');
178 jPlayer.type = 'application/x-java-applet';
179 jPlayer.setAttribute('archive', this.CortadoLocation);
180 jPlayer.id = '<?php echo htmlspecialchars( $id ) ?>';
181 jPlayer.width = '<?php echo htmlspecialchars( $width )?>';
182 jPlayer.height = '<?php echo htmlspecialchars( $height )?>';
185 'code': 'com.fluendo.player.Cortado',
186 'archive': 'cortado-wmf-r46643.jar',
187 'url': '<?php echo htmlspecialchars( $media_url )?>',
189 'keepAspect': 'true',
190 'video': '<?php echo htmlspecialchars( $video )?>',
191 'audio': '<?php echo htmlspecialchars( $audio )?>',
193 'showStatus': 'hide',
195 'bufferSize': '8192',
200 'duration':'<?php echo htmlspecialchars( $duration )?>',
206 var p = document.createElement('param');
208 p.value = params[name];
209 jPlayer.appendChild(p);
211 var pHolder = document.getElementById('jPlayer');
213 pHolder.appendChild( jPlayer );
217 <script type="text/javascript">