Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Player not work on iphone/ipad


I use jwplayer how video player in video pages.. example - http://fff.satellite.fm/film/a-grand-pursuit/
The code for the video player include the path to the file:

var $video = jwplayer( 'video-39907' ).setup( {
file : 'http://fff.satellite.fm/wp-content/fff-uploads-bucket/2016/12/MAFF-A-Grand-Pursuit-Trailer.mp4',
type : 'mp4',
image : 'http://fff.satellite.fm/wp-content/fff-uploads-bucket/2015/10/A-Grand-Pursuit-Vertical.jpg (Not automatically expanded because 4MB is too large. You can expand it anyway or open it in a new window.) ',
mediaid : 'fBmNw3v7'
} );

but if someone look to the page code they can copy and paste the video url and see/download the video.. so what I'm trying to do is server the video using a PHP script.. so I can make some checks in that PHP script to server or not the video.. on desktop the script work (at least on my side) but on iphone/ipad not work.

var $video = jwplayer( 'video-39907' ).setup( {
file : 'http://fff.satellite.fm/?&nfm=play&nff=39907&nfv=43357&nfb=410237682586bfc29845444.20339093,
type : 'mp4',
image : 'http://fff.satellite.fm/wp-content/fff-uploads-bucket/2015/10/A-Grand-Pursuit-Vertical.jpg (Not automatically expanded because 4MB is too large. You can expand it anyway or open it in a new window.) ',
mediaid : 'fBmNw3v7'
} );

Any help?

2 Community Answers

d...

User  
0 rated :

here is the script:

$file = 'PATH TO THE FILE';
$mime_type = 'MIME TYPE';

// Init
$s = new fff_sendfile();
// Set content type
$s->contentType( $mime_type );
// Send the file
try {
$s->send( $file );
} catch ( \Exception $e ) {
die( $e->getMessage() );
}
exit;

/**
* Sends a file to a client, with support for (multiple) range requests.
* It is also able to throttle the download.",
*/
class fff_sendfile {

/**
* if false we set content disposition from file that will be sent
* @var mixed $disposition
*/
private $disposition = FALSE;

/**
* throttle speed in secounds
* @var float $sec
*/
private $sec = 0.1;

/**
* bytes per $sec
* @var int $bytes
*/
private $bytes = 40960;

/**
* if contentType is false we try to guess it
* @var mixed $contentType
*/
private $type = FALSE;

/**
* set content disposition
* @param type $file_name
*/
public function contentDisposition( $file_name = FALSE ) {
$this->disposition = $file_name;
}

/**
* set throttle speed
* @param float $sec
* @param int $bytes
*/
public function throttle( $sec = 0.1, $bytes = 40960 ) {
$this->sec = $sec;
$this->bytes = $bytes;
}

/**
* set content mime type if false we try to guess it
* @param string $content_type
*/
public function contentType( $content_type = null ) {
$this->type = $content_type;
}

/**
* get name from path info
* @param type $file
* @return type
*/
private function name( $file ) {
$info = pathinfo( $file );
return $info['basename'];
}

/**
* Sets-up headers and starts transfering bytes
*
* @param string $file_path
* @param boolean $withDisposition
* @throws Exception
*/
public function send( $file_path, $disposition = TRUE, $download = FALSE ) {

if ( ! is_readable( $file_path ) ) {
throw new \Exception( 'File not found or inaccessible!' );
}

$size = filesize( $file_path );
if ( ! $this->disposition ) {
$this->disposition = $this->name( $file_path );
}

if ( ! $this->type ) {
$this->type = $this->getContentType( $file_path );
}

//turn off output buffering to decrease cpu usage
$this->cleanAll();

// required for IE, otherwise Content-Disposition may be ignored
if ( ini_get( 'zlib.output_compression' ) ) {
ini_set( 'zlib.output_compression', 'Off' );
}

header( 'Content-Type: ' . $this->type );
if ( $disposition ) {
if ( $download ) {
header( 'Content-Disposition: attachment; filename="' . $this->disposition . '"' );
} else {
header( 'Content-Disposition: inline' );
}
}
header( 'Accept-Ranges: bytes' );

// The three lines below basically make the
// download non-cacheable
header( "Cache-control: private" );
header( 'Pragma: private' );
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );

// multipart-download and download resuming support
if ( isset( $_SERVER['HTTP_RANGE'] ) ) {
list( $a, $range ) = explode( "=", $_SERVER['HTTP_RANGE'], 2 );
list( $range ) = explode( ",", $range, 2 );
list( $range, $range_end ) = explode( "-", $range );
$range = intval( $range );
if ( ! $range_end ) {
$range_end = $size - 1;
} else {
$range_end = intval( $range_end );
}
$new_length = $range_end - $range + 1;
header( "HTTP/1.1 206 Partial Content" );
header( "Content-Length: $new_length" );
header( "Content-Range: bytes $range-$range_end/$size" );
} else {
$new_length = $size;
header( "Content-Length: " . $size );
}

/* output the file itself */
$chunksize = $this->bytes; //you may want to change this
$bytes_send = 0;

$file = @fopen( $file_path, 'rb' );
if ( $file ) {
if ( isset( $_SERVER['HTTP_RANGE'] ) ) {
fseek($file, $range);
}
while ( ! feof( $file ) && ( ! connection_aborted() ) && ( $bytes_send < $new_length ) ) {
$buffer = fread( $file, $chunksize );
echo ( $buffer );
flush();
usleep( $this->sec * 1000000 );
$bytes_send += strlen( $buffer );
}
fclose( $file );
} else {
throw new \Exception( 'Error - can not open file.' );
}
die();
}

/**
* method for getting mime type of a file
* @param string $path
* @return string $mime_type
*/
private function getContentType( $path ) {
$result = FALSE;
if ( is_file( $path ) === TRUE ) {
if ( function_exists( 'finfo_open' ) === TRUE ) {
$finfo = finfo_open( FILEINFO_MIME_TYPE );
if ( is_resource( $finfo ) === TRUE ) {
$result = finfo_file( $finfo, $path );
}
finfo_close( $finfo );
} else if ( function_exists( 'mime_content_type' ) === TRUE ) {
$result = preg_replace( '~^(.+);.*$~', '$1', mime_content_type( $path ) );
} else if ( function_exists( 'exif_imagetype' ) === TRUE ) {
$result = image_type_to_mime_type( exif_imagetype( $path ) );
}
}
return $result;
}

/**
* clean all buffers
*/
private function cleanAll() {
while ( ob_get_level() ) {
ob_end_clean();
}
}

}

Alex

JW Player Support Agent  
0 rated :

Hi there,

My name is Alex and I am one of the Team Leads of the Support Team at JW Player. I will be more than happy to assist you with your questions.

Assisting with writing custom code for customers is not something that is within our scope of support. With that being said, I recommend that you take a look at the URL (Token) Signing feature we provide if you are looking for a way to protect your video URLs from being taken off of your page.

Since the video looks like it would be hosted externally, we wouldn’t be able to protect the actual video URL but you can protect the player URL. This means you can add the MP4s URL to your JW Player dashboard and then embed it using the “Embed” feature of the dashboard which will generate a single-line JavaScript library URL that is tokenized and set to expire in whatever amount of time you configure it to.

Alternatively, you can also choose to upload your MP4s to our platform which would give you the ability to also tokenize the video URLs themselves.

Please let me know if you need any more help or have any other questions.

Thank you!

This question has received the maximum number of answers.