| Current Path : /var/www/components/com_yendifvideoshare/views/player/tmpl/ |
| Current File : /var/www/components/com_yendifvideoshare/views/player/tmpl/html5.php |
<?php
/**
* @version 1.2.9
* @package Com_YendifVideoShare
* @author PluginsWare Interactive Pvt. Ltd <admin@yendifplayer.com>
* @copyright Copyright (c) 2012 - 2021 PluginsWare Interactive Pvt. Ltd. All Rights Reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
$app = JFactory::getApplication();
// Video Sources
$sources = array();
switch ( $this->item->type ) {
case 'youtube':
$sources['youtube'] = array(
'src' => $this->item->youtube,
'type' => 'video/youtube',
'label' => ''
);
break;
case 'vimeo':
$sources['vimeo'] = array(
'src' => $this->item->vimeo,
'type' => 'video/vimeo',
'label' => ''
);
break;
case 'rtmp':
if ( ! empty( $this->item->hls ) ) {
$sources['hls'] = array(
'src' => $this->item->hls,
'type' => 'application/x-mpegurl',
'label' => ''
);
}
if ( ! empty( $this->item->dash ) ) {
$sources['dash'] = array(
'src' => $this->item->dash,
'type' => 'application/dash+xml',
'label' => ''
);
}
break;
default:
$this->item->type = 'default';
$sources = array();
// SD
$ext = pathinfo( $this->item->mp4, PATHINFO_EXTENSION );
if ( ! in_array( $ext, array( 'webm', 'ogv' ) ) ) {
$ext = 'mp4';
}
$sources['sd'] = array(
'src' => $this->item->mp4,
'type' => 'video/' . $ext,
'label' => 'SD'
);
// HD
if ( ! empty( $this->item->mp4_hd ) ) {
$sources['hd'] = array(
'src' => $this->item->mp4_hd,
'type' => 'video/mp4',
'label' => 'HD'
);
}
// WebM
if ( ! empty( $this->item->webm ) ) {
$sources['webm'] = array(
'src' => $this->item->webm,
'type' => 'video/webm',
'label' => ''
);
}
// OGV
if ( ! empty( $this->item->ogv ) ) {
$sources['ogv'] = array(
'src' => $this->item->ogv,
'type' => 'video/ogv',
'label' => ''
);
}
}
// Video Tracks
$tracks = array();
if ( ! empty( $this->item->captions ) ) {
$tracks[] = $this->item->captions;
}
// Video Attributes
$attributes = array(
'id' => 'player',
'style' => 'width: 100%; height: 100%;',
'controls' => '',
'playsinline' => ''
);
if ( $this->params->get( 'loop' ) ) {
$attributes['loop'] = true;
}
if ( ! empty( $this->item->image ) ) {
$attributes['poster'] = $this->item->image;
}
// Player Settings
$excerpt = '';
if ( $this->item->id > 0 ) {
$excerpt = $this->item->meta_description;
if ( empty( $excerpt ) && ! empty( $this->item->description ) ) {
$excerpt = YendifVideoShareUtils::Truncate( $this->item->description );
$excerpt = str_replace( '...', '', $excerpt );
}
}
$settings = array(
'controlBar' => array(),
'bigPlayButton' => $this->params->get( 'playbtn' ) ? true : false,
'autoplay' => $this->params->get( 'autoplay' ) ? 1 : 0,
'muted' => $this->params->get( 'volume', -1 ) == 0 ? 1 : 0,
'playbackRates' => array( 0.5, 1, 1.5, 2 ),
'custom' => array(
'uid' => $app->input->getInt( 'uid', 0 ),
'siteUrl' => JURI::root(),
'videoId' => $this->item->id,
'videoType' => $this->item->type,
'videoTitle' => $this->item->title,
'videoExcerpt' => $excerpt,
'ipAddress' => $this->getIpAddress(),
'autoadvance' => ( $app->input->getInt( 'uid', 0 ) > 0 && $this->params->get( 'autoplaylist' ) ) ? 1 : 0,
'loop' => $this->params->get( 'loop' ) ? 1 : 0,
'volume' => (int) $this->params->get( 'volume', -1 )
)
);
if ( $this->params->get( 'controlbar' ) ) {
$controls = array(
'playpause' => 'PlayToggle',
'currenttime' => 'CurrentTimeDisplay',
'progress' => 'progressControl',
'duration' => 'durationDisplay',
'tracks' => 'SubtitlesButton',
'audio' => 'AudioTrackButton',
'quality' => 'qualitySelector',
'speed' => 'PlaybackRateMenuButton',
'volumebtn' => 'VolumePanel',
'fullscreen' => 'fullscreenToggle'
);
foreach ( $controls as $key => $control ) {
switch ( $key ) {
case 'quality':
$enabled = ( isset( $sources['hd'] ) || isset( $sources['hls'] ) || isset( $sources['dash'] ) ) ? 1 : 0;
break;
case 'tracks':
case 'audio':
$enabled = ! empty( $this->item->captions ) ? 1 : 0;
break;
default:
$enabled = $this->params->get( $key, 0 );
}
if ( ! $enabled ) {
unset( $controls[ $key ] );
}
}
$settings['controlBar']['children'] = array_values( $controls );
}
if ( ! isset( $settings['controlBar']['children'] ) || empty( $settings['controlBar']['children'] ) ) {
$attributes['class'] = 'vjs-no-control-bar';
}
if ( isset( $sources['youtube'] ) ) {
$settings['techOrder'] = array( 'youtube' );
$settings['youtube'] = array(
'iv_load_policy' => 3
);
parse_str( $sources['youtube']['src'], $queries );
if ( isset( $queries['start'] ) ) {
$settings['custom']['start'] = (int) $queries['start'];
}
if ( isset( $queries['t'] ) ) {
$settings['custom']['start'] = (int) $queries['t'];
}
if ( isset( $queries['end'] ) ) {
$settings['custom']['end'] = (int) $queries['end'];
}
}
if ( isset( $sources['vimeo'] ) ) {
$settings['techOrder'] = array( 'vimeo2' );
}
// Logo
$settings['custom']['license'] = array(
'secretKey' => $this->params->get( 'license' ),
'showLogo' => ! empty( $this->params->get( 'logo' ) ) ? 1 : 0,
'logoImage' => $this->params->get( 'logo' ),
'logoLink' => $this->params->get( 'logotarget', JUri::root() ),
'logoPosition' => $this->params->get( 'logoposition', 'bottomleft' ),
'logoOpacity' => (int) $this->params->get( 'logoalpha', 50 ) / 100,
'contextmenuLabel' => $this->canDo ? $app->get( 'sitename' ) : 'A Joomla Video Gallery'
);
// Ads
$settings['custom']['ads'] = array(
'enabled' => $this->hasAds() ? true : false,
'adTagURL' => $this->params->get( 'vasturl' ),
'showCountdown' => ( $this->params->get( 'ad_engine' ) == 'custom' && ! $this->params->get( 'show_adverts_timeframe' ) ) ? false : true
);
// Embed
$settings['custom']['embed'] = array(
'enabled' => ( $this->canDo && $this->params->get( 'embed' ) && $this->item->id > 0 ) ? true : false,
'code' => '<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;"><iframe src="' . JURI::root() . 'index.php?option=com_yendifvideoshare&view=player&id=' . $this->item->id . '&format=raw" style="width:100%;height:100%;position:absolute;left:0px;top:0px;overflow:hidden" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>'
);
// Share
$shareUrl = urlencode( $this->getURL() );
$shareTitle = urlencode( $this->item->title );
$shareImage = ! empty( $this->item->image ) ? urlencode( $this->item->image ) : '';
$settings['custom']['share'] = array(
'enabled' => ( $this->canDo && $this->params->get( 'share' ) && $this->item->id > 0 ) ? true : false,
'facebook_url' => "https://www.facebook.com/sharer/sharer.php?u={$shareUrl}",
'twitter_url' => "https://twitter.com/intent/tweet?text={$shareTitle}&url={$shareUrl}",
'linkedin_url' => "https://www.linkedin.com/shareArticle?url={$shareUrl}&title={$shareTitle}",
'pinterest_url' => "https://pinterest.com/pin/create/button/?url={$shareUrl}&media={$shareImage}&description={$shareTitle}",
'tumblr_url' => "https://www.tumblr.com/share/link?url={$shareUrl}&name={$shareTitle}"
);
// Download
$settings['custom']['download'] = array(
'enabled' => ( $this->canDo && $this->params->get( 'download' ) && $this->item->id > 0 && $this->item->type == 'default' ) ? true : false,
'url' => JUri::root() . 'index.php?option=com_yendifvideoshare&view=download&id=' . $this->item->id
);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<link rel="stylesheet" href="<?php echo JURI::root(); ?>media/yendifvideoshare/player/video-js.min.css?v=7.11.8" />
<?php if ( isset( $sources['hd'] ) ) : ?>
<link rel="stylesheet" href="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/quality-selector/quality-selector.css?v=1.2.5" />
<?php endif; ?>
<?php if ( isset( $sources['hls'] ) || isset( $sources['dash'] ) ) : ?>
<link rel="stylesheet" href="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/videojs-quality-menu/videojs-quality-menu.css?v=1.4.0" />
<?php endif; ?>
<link rel="stylesheet" href="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/overlay/videojs-overlay.css?v=2.1.4" />
<?php if ( $settings['custom']['ads']['enabled'] ) : ?>
<link rel="stylesheet" href="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/contrib-ads/videojs-contrib-ads.css?v=6.8.0" />
<link rel="stylesheet" href="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/ima/videojs.ima.css?v=1.11.0" />
<?php endif; ?>
<style type="text/css">
html,
body,
.video-js {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
.vjs-no-control-bar .vjs-control-bar {
display: none;
}
.video-js .vjs-control-bar {
background-color: rgba( 0, 0, 0, 0.5 );
}
.video-js .vjs-current-time,
.vjs-no-flex .vjs-current-time,
.video-js .vjs-duration,
.vjs-no-flex .vjs-duration {
display: block;
}
.video-js .vjs-subtitles-button .vjs-icon-placeholder:before {
content: "\f10d";
}
.video-js .vjs-menu li.vjs-selected:focus,
.video-js .vjs-menu li.vjs-selected:hover {
background-color: #fff;
color: #2b333f;
}
.vjs-quality-selector .vjs-menu li {
text-transform: uppercase;
}
.video-js .vjs-big-play-button {
width: 1.5em;
height: 1.5em;
top: 50%;
left: 50%;
margin-top: 0;
margin-left: 0;
background-color: rgba( 0, 0, 0, 0.5 );
border: none;
border-radius: 50%;
font-size: 6em;
line-height: 1.5em;
transform: translateX( -50% ) translateY( -50% );
}
.video-js:hover .vjs-big-play-button,
.video-js .vjs-big-play-button:focus {
background-color: rgba( 0, 0, 0, 0.7 );
}
.vjs-waiting .vjs-big-play-button {
display: none !important;
}
.vjs-ended .vjs-control-bar,
.vjs-ended .vjs-text-track-display,
.vjs-ended .vjs-logo {
display: none;
}
.vjs-ended .vjs-poster,
.vjs-ended .vjs-big-play-button {
display: block;
}
.vjs-logo {
margin: 5px;
opacity: 0;
cursor: pointer;
}
.vjs-has-started .vjs-logo {
opacity: 0.5;
transition: opacity 0.1s;
}
.vjs-has-started.vjs-user-inactive.vjs-playing .vjs-logo {
opacity: 0;
transition: opacity 1s;
}
.vjs-has-started .vjs-logo:hover {
opacity: 1;
}
.vjs-logo img {
display: block;
max-width: 100%;
}
.vjs-share,
.vjs-download {
margin: 5px;
cursor: pointer;
}
.vjs-share img,
.vjs-download img {
display: block;
margin: 0;
padding: 10px;
background-color: rgba( 0, 0, 0, 0.5 );
border-radius: 1px;
}
.vjs-share:hover img,
.vjs-download:hover img {
background-color: rgba( 0, 0, 0, 0.7 );
}
.vjs-download.vjs-has-share {
margin-top: 50px;
}
.vjs-has-started .vjs-share,
.vjs-has-started .vjs-download {
display: block;
visibility: visible;
opacity: 1;
transition: visibility .1s,opacity .1s;
}
.vjs-has-started.vjs-user-inactive.vjs-playing .vjs-share,
.vjs-has-started.vjs-user-inactive.vjs-playing .vjs-download {
visibility: visible;
opacity: 0;
transition: visibility 1s,opacity 1s;
}
.video-js .vjs-modal-dialog-embed-share {
background: #111 !important;
}
.video-js .vjs-modal-dialog-embed-share .vjs-close-button {
margin: 7px;
}
.video-js .vjs-embed-share {
display: flex !important;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.video-js .vjs-embed-share-content {
width: 100%;
}
.video-js .vjs-share-icons {
text-align: center;
}
.video-js .vjs-share-icon {
display: inline-block;
padding: 7px 10px;
line-height: 1;
}
.video-js .vjs-share-icon:hover {
opacity: 0.9;
}
.video-js .vjs-share-icon,
.video-js .vjs-share-icon:hover,
.video-js .vjs-share-icon:focus {
text-decoration: none;
}
.video-js .vjs-share-icon-facebook {
background-color: #3B5996;
}
.video-js .vjs-share-icon-twitter {
background-color: #55ACEE;
}
.video-js .vjs-share-icon-linkedin {
background-color: #006699;
}
.video-js .vjs-share-icon-pinterest {
background-color: #C00117;
}
.video-js .vjs-share-icon-tumblr {
background-color: #28364B;
}
.video-js .vjs-share-icon span {
color: #fff;
font-size: 24px;
}
.video-js .vjs-embed-url {
margin: 20px;
}
.video-js .vjs-embed-url p {
text-align: center;
text-transform: uppercase;
}
.video-js .vjs-embed-url input {
width: 100%;
padding: 7px;
background: #fff;
border: 1px solid #fff;
color: #000;
}
.video-js .vjs-embed-url input:focus {
border: 1px solid #fff;
outline-style: none;
}
.contextmenu {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
background-color: #2B333F;
background-color: rgba( 43, 51, 63, 0.7 );
border-radius: 2px;
z-index: 9999999999; /* make sure it shows on fullscreen */
}
.contextmenu-item {
margin: 0;
padding: 8px 12px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #FFF;
white-space: nowrap;
cursor: pointer;
}
</style>
<?php
if ( ! empty( $this->params->get( 'custom_css' ) ) ) {
printf( '<style type="text/css">%s</style>', $this->params->get( 'custom_css' ) );
}
?>
</head>
<body id="body" class="vjs-waiting">
<?php
$_attributes = array();
foreach ( $attributes as $key => $value ) {
if ( '' === $value ) {
$_attributes[] = $key;
} else {
$_attributes[] = sprintf( '%s="%s"', $key, $value );
}
}
$attributes = implode( ' ', $_attributes );
?>
<video-js <?php echo $attributes; ?>>
<?php
// Video Sources
foreach ( $sources as $source ) {
printf(
'<source type="%s" src="%s" label="%s" />',
$source['type'],
$source['src'],
( isset( $source['label'] ) ? $source['label'] : '' )
);
}
// Video Tracks
foreach ( $tracks as $track ) {
printf(
'<track src="%s" kind="subtitles" label="Subtitles On" default>',
$track
);
}
?>
</video-js>
<div id="vjs-embed-share" class="vjs-embed-share" style="display: none;">
<div class="vjs-embed-share-content">
<?php if ( ! empty( $settings['custom']['share']['enabled'] ) ) : ?>
<!-- Share Icons -->
<div class="vjs-share-icons">
<a href="<?php echo $settings['custom']['share']['facebook_url']; ?>" class="vjs-share-icon vjs-share-icon-facebook" target="_blank">
<span class="vjs-icon-facebook"></span>
</a>
<a href="<?php echo $settings['custom']['share']['twitter_url']; ?>" class="vjs-share-icon vjs-share-icon-twitter" target="_blank">
<span class="vjs-icon-twitter"></span>
</a>
<a href="<?php echo $settings['custom']['share']['linkedin_url']; ?>" class="vjs-share-icon vjs-share-icon-linkedin" target="_blank">
<span class="vjs-icon-linkedin"></span>
</a>
<a href="<?php echo $settings['custom']['share']['pinterest_url']; ?>" class="vjs-share-icon vjs-share-icon-pinterest" target="_blank">
<span class="vjs-icon-pinterest"></span>
</a>
<a href="<?php echo $settings['custom']['share']['tumblr_url']; ?>" class="vjs-share-icon vjs-share-icon-tumblr" target="_blank">
<span class="vjs-icon-tumblr"></span>
</a>
</div>
<?php endif; ?>
<?php if ( ! empty( $settings['custom']['embed']['enabled'] ) ) : ?>
<!-- Embed URL -->
<div class="vjs-embed-url">
<p><?php echo JText::_( 'COM_YENDIFVIDEOSHARE_EMBED_TITLE' ); ?></p>
<input type="text" id="vjs-copy-embed-url" value="<?php echo htmlspecialchars( $settings['custom']['embed']['code'] ); ?>" readonly />
</div>
<?php endif; ?>
</div>
</div>
<div id="contextmenu" class="contextmenu" style="display: none;">
<div class="contextmenu-item"><?php echo $settings['custom']['license']['contextmenuLabel']; ?></div>
</div>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/video.min.js?v=7.11.8" type="text/javascript"></script>
<?php if ( isset( $sources['hd'] ) ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/quality-selector/silvermine-videojs-quality-selector.min.js?v=1.2.5" type="text/javascript"></script>
<?php endif; ?>
<?php if ( isset( $sources['hls'] ) || isset( $sources['dash'] ) ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/videojs-quality-menu/videojs-quality-menu.min.js?v=1.4.0" type="text/javascript"></script>
<?php endif; ?>
<?php if ( isset( $sources['youtube'] ) ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/youtube/Youtube.min.js?v=2.6.1" type="text/javascript"></script>
<?php endif; ?>
<?php if ( isset( $settings['custom']['start'] ) || isset( $settings['custom']['end'] ) ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/offset/videojs-offset.min.js?v=2.1.3" type="text/javascript"></script>
<?php endif; ?>
<?php if ( isset( $sources['vimeo'] ) ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/vimeo/videojs-vimeo2.min.js?v=1.3.0" type="text/javascript"></script>
<?php endif; ?>
<?php if ( isset( $sources['hls'] ) || isset( $sources['dash'] ) ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/http-streaming/videojs-http-streaming.min.js?v=2.8.2" type="text/javascript"></script>
<?php endif; ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/overlay/videojs-overlay.min.js?v=2.1.4" type="text/javascript"></script>
<?php if ( $settings['custom']['ads']['enabled'] ) : ?>
<script src="https://imasdk.googleapis.com/js/sdkloader/ima3.js" type="text/javascript"></script>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/contrib-ads/videojs-contrib-ads.min.js?v=6.8.0" type="text/javascript"></script>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/ima/videojs.ima.min.js?v=1.11.0" type="text/javascript"></script>
<?php endif; ?>
<?php if ( $settings['autoplay'] ) : ?>
<script src="<?php echo JURI::root(); ?>media/yendifvideoshare/player/plugins/can-autoplay/can-autoplay.min.js?v=3.0.0" type="text/javascript"></script>
<?php endif; ?>
<script type="text/javascript">
var License = function( player, settings ) {
function a(e){var d=document.createElement("a");d.href=e;return d.hostname.replace("www.","")}function b(e){for(var d=0,f=e.length-1;0<=f;f--)d+=9187263540*e.charCodeAt(f);return(""+d).substring(0,10)}function c(e){for(var d=0,f=0;f<e.length;f++)d+=2465130798*e.charCodeAt(f);return(""+98765243*d).substring(0,10)};
var d = a( settings.custom.siteUrl );
if ( settings.custom.license.secretKey == 'Y'+b(d)+'<'+c(d)+'>!' ) {
if ( settings.custom.license.showLogo ) {
var attributes = [];
attributes['src'] = settings.custom.license.logoImage;
attributes['style'] = 'opacity: ' + settings.custom.license.logoOpacity;
var align;
switch ( settings.custom.license.logoPosition ) {
case 'topleft':
align = 'top-left';
break;
case 'topright':
align = 'top-right';
break;
case 'bottomright':
align = 'bottom-right';
break;
default:
align = 'bottom-left';
break;
}
if ( settings.custom.license.logoLink ) {
attributes['onclick'] = "top.window.location.href='" + settings.custom.license.logoLink + "';";
}
window.overlays.push({
content: '<img ' + combineAttributes( attributes ) + '/>',
class: 'vjs-logo',
align: align,
start: 'controlsshown',
end: 'controlshidden',
showBackground: false
});
}
} else {
window.overlays.push({
content: '<a href="http://yendifplayer.com/" target="_blank" style="display:inline-block;background-color:#E34D2B;margin:5px;padding:5px 6px;color:#FFF;font-family:Trebuchet MS;font-size:12px;font-style:italic;text-decoration:none;-moz-opacity:0.7;opacity:0.7;z-index:0011;cursor:pointer;">Powered by Yendif !</a>',
align: 'bottom-left',
start: 'controlsshown',
end: 'controlshidden',
showBackground: false
});
}
}
// Listen to the player initialized event
window.addEventListener( 'player.init', function( evt ) {
var license = new License( evt.detail.player, evt.detail.settings );
});
</script>
<script type="text/javascript">
var Ads = function( player, settings ) {
this.player = player;
this.settings = settings;
this.initialized = false;
// Remove controls from the player on iPad to stop native controls from stealing
// our click
try {
var contentPlayer = document.getElementById( 'player_html5_api' );
if ( ( navigator.userAgent.match( /iPad/i ) || navigator.userAgent.match( /Android/i ) ) && contentPlayer.hasAttribute( 'controls' ) ) {
contentPlayer.removeAttribute( 'controls' );
}
} catch ( err ) {
// console.log( err );
}
// Start ads when the video player is clicked, but only the first time it's
// clicked.
this.startEvent = 'click';
if ( navigator.userAgent.match( /iPhone/i ) || navigator.userAgent.match( /iPad/i ) || navigator.userAgent.match( /Android/i ) ) {
this.startEvent = 'touchend';
}
// ...
var options = {
id: 'player',
adTagUrl: this.getAdTagURL(),
showCountdown: this.settings.custom.ads.showCountdown,
vpaidMode: google.ima.ImaSdkSettings.VpaidMode.ENABLED,
adsManagerLoadedCallback: this.adsManagerLoadedCallback.bind( this )
};
this.player.ima( options );
this.wrapperDiv = document.getElementById( 'player' );
this.boundInit = this.init.bind( this );
this.wrapperDiv.addEventListener( this.startEvent, this.boundInit );
this.player.one( 'play', this.boundInit );
};
Ads.prototype.init = function() {
if ( this.initialized ) {
return;
}
this.initialized = true;
this.player.ima.initializeAdDisplayContainer();
this.wrapperDiv.removeEventListener( this.startEvent, this.boundInit );
};
Ads.prototype.adsManagerLoadedCallback = function() {
var events = [
google.ima.AdEvent.Type.ALL_ADS_COMPLETED,
google.ima.AdEvent.Type.CLICK,
google.ima.AdEvent.Type.COMPLETE,
google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
google.ima.AdEvent.Type.FIRST_QUARTILE,
google.ima.AdEvent.Type.LOADED,
google.ima.AdEvent.Type.MIDPOINT,
google.ima.AdEvent.Type.PAUSED,
google.ima.AdEvent.Type.RESUMED,
google.ima.AdEvent.Type.STARTED,
google.ima.AdEvent.Type.THIRD_QUARTILE
];
for ( var index = 0; index < events.length; index++ ) {
this.player.ima.addEventListener(
events[ index ],
this.onAdEvent.bind( this ) );
}
};
Ads.prototype.onAdEvent = function( event ) {
switch ( event.type ) {
case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:
if ( this.player.paused && ! this.player.ended ) {
this.player.play();
}
break;
}
};
Ads.prototype.getAdTagURL = function() {
var url = this.settings.custom.ads.adTagURL;
url = url.replace( '[domain]', encodeURIComponent( this.settings.custom.siteUrl ) );
url = url.replace( '[player_width]', this.player.currentWidth() );
url = url.replace( '[player_height]', this.player.currentHeight() );
url = url.replace( '[random_number]', Date.now() );
url = url.replace( '[timestamp]', Date.now() );
url = url.replace( '[page_url]', encodeURIComponent( window.top.location ) );
url = url.replace( '[referrer]', encodeURIComponent( document.referrer ) );
url = url.replace( '[ip_address]', this.settings.custom.ipAddress );
url = url.replace( '[post_id]', this.settings.custom.videoId );
url = url.replace( '[post_title]', encodeURIComponent( this.settings.custom.videoTitle ) );
url = url.replace( '[post_excerpt]', encodeURIComponent( this.settings.custom.videoExcerpt ) );
url = url.replace( '[video_file]', encodeURIComponent( this.player.currentSrc() ) );
url = url.replace( '[video_duration]', this.player.duration() || '' );
url = url.replace( '[autoplay]', this.settings.autoplay );
return url;
};
</script>
<script type="text/javascript">
'use strict';
// Vars
var settings = <?php echo json_encode( $settings ); ?>;
settings.html5 = {
vhs: {
overrideNative: ! videojs.browser.IS_ANY_SAFARI,
}
};
var overlays = [];
/**
* Merge attributes.
*
* @since 2.0.0
* @param {array} attributes Attributes array.
* @return {string} str Merged attributes string to use in an HTML element.
*/
function combineAttributes( attributes ) {
var str = '';
for ( var key in attributes ) {
str += ( key + '="' + attributes[ key ] + '" ' );
}
return str;
}
/**
* Update video views count.
*
* @since 2.0.0
*/
function updateViewsCount() {
var xmlhttp;
if ( window.XMLHttpRequest ) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
};
xmlhttp.onreadystatechange = function() {
if ( 4 == xmlhttp.readyState && 200 == xmlhttp.status ) {
if ( xmlhttp.responseText ) {
// Do nothing
}
}
};
xmlhttp.open( 'GET', '<?php echo JURI::root(); ?>index.php?option=com_yendifvideoshare&view=ajax&task=updateviews&id=' + settings.custom.videoId, true );
xmlhttp.send();
}
/**
* Check unmuted autoplay support.
*
* @since 2.0.0
*/
function checkUnmutedAutoplaySupport() {
canAutoplay
.video({ timeout: 100, muted: false })
.then(function( response ) {
if ( response.result === false ) {
// Unmuted autoplay is not allowed
checkMutedAutoplaySupport();
} else {
// Unmuted autoplay is allowed
settings.autoplay = true;
initPlayer();
}
});
}
/**
* Check muted autoplay support.
*
* @since 2.0.0
*/
function checkMutedAutoplaySupport() {
canAutoplay
.video({ timeout: 100, muted: true })
.then(function( response ) {
if ( response.result === false ) {
// Muted autoplay is not allowed
settings.autoplay = false;
} else {
// Muted autoplay is allowed
settings.autoplay = true;
settings.muted = true;
}
initPlayer();
});
}
/**
* Initialize the player.
*
* @since 2.0.0
*/
function initPlayer() {
var player = videojs( 'player', settings );
// Dispatch an event
var evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( 'player.init', false, false, { player: player, settings: settings } );
window.dispatchEvent( evt );
// Listen to the player events
player.ready(function() {
document.getElementById( 'body' ).className = '';
if ( settings.custom.volume > -1 ) {
player.volume( settings.custom.volume / 100 );
}
});
player.one( 'play', function() {
if ( settings.custom.videoId > 0 ) {
updateViewsCount();
}
});
player.on( 'playing', function() {
player.trigger( 'controlsshown' );
});
player.on( 'ended', function() {
player.trigger( 'controlshidden' );
});
// Offset
var offset = {};
if ( settings.custom.start ) {
offset.start = settings.custom.start;
}
if ( settings.custom.end ) {
offset.end = settings.custom.end;
}
if ( Object.keys( offset ).length > 1 ) {
offset.restart_beginning = false;
player.offset( offset );
}
// Quality
if ( settings.custom.videoType == 'rtmp' ) {
player.qualityMenu();
}
// Share
if ( settings.custom.embed.enabled || settings.custom.share.enabled ) {
overlays.push({
content: '<img src="' + settings.custom.siteUrl + 'media/yendifvideoshare/assets/site/images/share.png" id="vjs-share-btn" />',
class: 'vjs-share',
align: 'top-right',
start: 'controlsshown',
end: 'controlshidden',
showBackground: false
});
}
// Download
if ( settings.custom.download.enabled ) {
var __class = 'vjs-download';
if ( settings.custom.embed.enabled || settings.custom.share.enabled ) {
__class += ' vjs-has-share';
}
overlays.push({
content: '<a href="' + settings.custom.download.url + '" style="text-decoration:none;" target="_blank"><img src="' + settings.custom.siteUrl + 'media/yendifvideoshare/assets/site/images/download.png" /></a>',
class: __class,
align: 'top-right',
start: 'controlsshown',
end: 'controlshidden',
showBackground: false
});
}
// Overlay
if ( overlays.length > 0 ) {
player.overlay({
content: '',
overlays: overlays
});
if ( settings.custom.embed.enabled || settings.custom.share.enabled ) {
var options = {};
options.content = document.getElementById( 'vjs-embed-share' );
options.temporary = false;
var ModalDialog = videojs.getComponent( 'ModalDialog' );
var modal = new ModalDialog( player, options );
modal.addClass( 'vjs-modal-dialog-embed-share' );
player.addChild( modal );
var wasPlaying = true;
document.getElementById( 'vjs-share-btn' ).addEventListener( 'click', function() {
wasPlaying = ! player.paused;
modal.open();
});
modal.on( 'modalclose', function() {
if ( wasPlaying ) {
player.play();
}
});
}
if ( settings.custom.embed.enabled ) {
document.getElementById( 'vjs-copy-embed-url' ).addEventListener( 'focus', function() {
document.getElementById( 'vjs-copy-embed-url' ).select();
document.execCommand( 'copy' );
});
}
}
// Initialize Ads
if ( settings.custom.ads.enabled ) {
var ads = new Ads( player, settings );
}
// AutoAdvance
if ( settings.custom.autoadvance ) {
player.on( 'ended', function() {
parent.postMessage(
{
message: 'ON_YENDIFVIDEOSHARE_ENDED',
id: settings.custom.uid,
loop: settings.custom.loop,
},
'*'
);
});
}
}
if ( settings.autoplay ) {
checkUnmutedAutoplaySupport();
} else {
initPlayer();
}
// Custom contextmenu
if ( settings.custom.license.contextmenuLabel ) {
var contextmenu = document.getElementById( 'contextmenu' );
var timeout_handler = '';
document.addEventListener( 'contextmenu', function( e ) {
if ( 3 === e.keyCode || 3 === e.which ) {
e.preventDefault();
e.stopPropagation();
var width = contextmenu.offsetWidth,
height = contextmenu.offsetHeight,
x = e.pageX,
y = e.pageY,
doc = document.documentElement,
scrollLeft = ( window.pageXOffset || doc.scrollLeft ) - ( doc.clientLeft || 0 ),
scrollTop = ( window.pageYOffset || doc.scrollTop ) - ( doc.clientTop || 0 ),
left = x + width > window.innerWidth + scrollLeft ? x - width : x,
top = y + height > window.innerHeight + scrollTop ? y - height : y;
contextmenu.style.display = '';
contextmenu.style.left = left + 'px';
contextmenu.style.top = top + 'px';
clearTimeout( timeout_handler );
timeout_handler = setTimeout(function() {
contextmenu.style.display = 'none';
}, 1500 );
}
});
if ( settings.custom.logoLink ) {
contextmenu.addEventListener( 'click', function() {
top.window.location.href = settings.custom.logoLink;
});
}
document.addEventListener( 'click', function() {
contextmenu.style.display = 'none';
});
}
</script>
</body>
</html>