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 deprecated 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 // load the http GETS:
18 // set the parent domain if provided
19 $parent_domain = isset( $_GET['parent_domain'] ) ?
$_GET['parent_domain'] : false;
21 // default to null media in not provided:
22 $media_url = isset( $_GET['media_url'] ) ?
$_GET['media_url'] : false;
23 if( strval( $media_url ) === '' ){
24 error_out( 'invalid or missing media URL' );
27 // default duration to 30 seconds if not provided. (ideally cortado would read this from the video file)
28 //$duration = ( isset( $_GET['duration'] ) ) ? $_GET['duration'] : 0;
29 $duration = filter_input( INPUT_GET
, 'duration', FILTER_SANITIZE_NUMBER_INT
);
30 if( is_null( $duration ) ||
$duration === false ){
34 // id (set to random if none provided)
35 //$id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 'vid_' . rand( '10000000' );
36 $id = isset( $_GET['id'] ) ?
$_GET['id'] : false;
37 if( is_null( $id ) ||
$id === false ){
38 $id = 'vid_' . rand( 0, 10000000 );
41 $width = filter_input( INPUT_GET
, 'width', FILTER_SANITIZE_NUMBER_INT
);
42 if( is_null( $width ) ||
$width === false ){
45 $height = filter_input( INPUT_GET
, 'height', FILTER_SANITIZE_NUMBER_INT
);
47 $stream_type = ( isset( $_GET['stream_type'] ) ) ?
$_GET['stream_type'] : 'video';
48 if( $stream_type == 'video' ){
49 $audio = $video = 'true';
50 if( is_null( $height ) ||
$height === false )
52 } else { // if( $stream_type == 'audio' )
55 if( is_null( $height ) ||
$height === false )
59 // everything good output page:
62 'media_url' => $media_url,
65 'duration' => $duration,
68 'parent_domain' => $parent_domain
73 * JS escape function copied from MediaWiki's Xml::escapeJsString()
75 function escapeJsString( $string ) {
76 // See ECMA 262 section 7.8.4 for string literal format
84 # To avoid closing the element or CDATA section
88 # To avoid any complaints about bad entity refs
91 # Work around https://bugzilla.mozilla.org/show_bug.cgi?id=274152
92 # Encode certain Unicode formatting chars so affected
93 # versions of Gecko don't misinterpret our strings;
94 # this is a common problem with Farsi text.
95 "\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER
96 "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
98 return strtr( $string, $pairs );
101 function error_out( $error = '' ){
102 output_page( array( 'error' => $error ) );
106 function output_page( $params ){
108 ?
><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
109 <html xmlns
="http://www.w3.org/1999/xhtml">
111 <meta http
-equiv
="Content-Type" content
="text/html; charset=iso-8859-1" />
112 <title
>cortado_embed
</title
>
113 <script type
="text/javascript">
114 <?php
//set the parent domain:
115 if( $parent_domain ){?
>
117 document
.domain
= '<?php echo htmlspecialchars( $parent_domain ) ?>';
120 console
.log('could not set domain to <?php echo htmlspecialchars( $parent_domain ) ?>');
125 function setGlobalJplayer(){
126 jPlayer
= document
.getElementById('<?php echo htmlspecialchars( $id ) ?>');
129 <style type
="text/css">
139 <body onload
="setGlobalJplayer()" >
141 $appid = ( preg_match( "/MSIE/i", getenv( "HTTP_USER_AGENT" ) ) ) ?
'' : 'classid="java:com.fluendo.player.Cortado.class"';
142 if( empty( $error ) ){ ?
>
143 <div id
="jPlayer"></div
>
144 <OBJECT id
="<?php echo htmlspecialchars( $id ) ?>"
145 code
="com.fluendo.player.Cortado.class"
147 archive
="binPlayers/cortado/cortado-wmf-r46643.jar"
148 width
="<?php echo htmlspecialchars( $width ) ?>"
149 height
="<?php echo htmlspecialchars( $height ) ?>" >
150 <param name
="url" value
="<?php echo htmlspecialchars( $media_url ) ?>" />
151 <param name
="local" value
="false"/>
152 <param name
="keepaspect" value
="true" />
153 <param name
="video" value
="<?php echo htmlspecialchars( $video ) ?>" />
154 <param name
="audio" value
="<?php echo htmlspecialchars( $audio ) ?>" />
155 <param name
="seekable" value
="false" />
156 <?php
if( $duration != 0 ){ ?
>
157 <param name
="duration" value
="<?php echo htmlspecialchars( $duration ) ?>" />
159 <param name
="showStatus" value
="hide" />
160 <param name
="autoPlay" value
="true" />
161 <param name
="BufferSize" value
="8192" />
162 <param name
="BufferHigh" value
="30" />
163 <param name
="BufferLow" value
="5" />
166 <b
>Error
:</b
> <?php
echo htmlspecialchars( $error ) ?
>
175 javascript envoked version:
177 jPlayer = document.createElement('OBJECT');
178 jPlayer.setAttribute('classid', 'java:com.fluendo.player.Cortado.class');
179 jPlayer.type = 'application/x-java-applet';
180 jPlayer.setAttribute('archive', this.CortadoLocation);
181 jPlayer.id = '<?php echo htmlspecialchars( $id ) ?>';
182 jPlayer.width = '<?php echo htmlspecialchars( $width )?>';
183 jPlayer.height = '<?php echo htmlspecialchars( $height )?>';
186 'code': 'com.fluendo.player.Cortado',
187 'archive': 'cortado-wmf-r46643.jar',
188 'url': '<?php echo htmlspecialchars( $media_url )?>',
190 'keepAspect': 'true',
191 'video': '<?php echo htmlspecialchars( $video )?>',
192 'audio': '<?php echo htmlspecialchars( $audio )?>',
194 'showStatus': 'hide',
196 'bufferSize': '8192',
201 'duration':'<?php echo htmlspecialchars( $duration )?>',
207 var p = document.createElement('param');
209 p.value = params[name];
210 jPlayer.appendChild(p);
212 var pHolder = document.getElementById('jPlayer');
214 pHolder.appendChild( jPlayer );
218 <script type="text/javascript">