Moved video players and relative shortcodes

parent b364ecb3
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
namespace wp_SexHackMe;
if(!class_exists('SexhackVideoJSPlayer')) {
class SexhackVideoJSPlayer
{
public function __construct()
{
sexhack_log('SexhackVideoJSPlayer() Instanced');
add_shortcode("sexvideo", array( $this, "sexvideo_shortcode"));
}
public function addPlayer($vurl, $posters="", $projection="180_LR")
{
$uid = uniqid('sexvideo_');
//$uid = "antani";
$html = "<video id='$uid' class='video-js vjs-default-skin vjs-2-1 vjs-big-play-centered' style='width: 100%; height: 100%;' controls poster='$posters'>\n";
//$html.= '<script src="https://s3.deovr.com/version/1/js/bundle.js" async></script>';
//$html .= "<deo-video id='$uid'>\n";
//$html .= ' <source src="'.$vurl.'" quality="1080p" type="application/x-mpegURL">'."\n";
$html .= '</video>'."\n";
//$html .= "</deo-video>\n";
$html .= "<script language='javascript'>\n";
$html .= "$(window).on('load', function() {\n";
//$html .= " videojs.log.level('debug');\n";
$html .= " var player = videojs('$uid', {\n";
$html .= " html5: {\n";
$html .= " vhs: {\n";
$html .= " overrideNative: !videojs.browser.IS_SAFARI\n";
$html .= " },\n";
$html .= " nativeAudioTracks: false,\n";
$html .= " nativeVideoTracks: false\n";
$html .= " }});\n";
$html .= " player.src({ src: '$vurl', type: 'application/x-mpegURL'});\n";
//if($_GET['antani']) {
$html .= " player.xr();";
//} else {
// $html .= " player.mediainfo = player.mediainfo || {};\n";
// $html .= " player.mediainfo.projection = '$projection';\n";
// $html .= " player.vr({projection: '$projection', debug: false, forceCardboard: true});\n";
//}
//$html .= " player.xr();";
$html .= '});'."\n";
$html .= "</script>";
return $html;
}
public function sexvideo_shortcode($attr, $cont)
{
extract( shortcode_atts(array(
"url" => '',
"posters" => '',
), $attr));
return "<div class='sexvideo_videojs'>" . $this->addPlayer($url, $posters) . "</div>";
}
}
}
$SEXHACK_SECTION = array(
'class' => 'SexhackVideoJSPlayer',
'description' => 'Add VideoJS Video Player',
'name' => 'sexhackme_videojs_player'
);
?>
......@@ -182,9 +182,9 @@ if(!class_exists('SexHackVideoGallery')) {
$is_sexhack_video = get_query_var('wooprod', false);
if($is_sexhack_video ) {
set_query_var( 'post_type', 'sexhack_video' );
if ( file_exists( plugin_dir_path(__DIR__) . '/template/'.$template)) {
sexhack_log("NEW TEMPLATE!: ".plugin_dir_path(__DIR__) . '/template/'.$template);
return plugin_dir_path(__DIR__) . '/template/'.$template;
if ( file_exists( plugin_dir_path(__DIR__) . '/templates/'.$template)) {
sexhack_log("NEW TEMPLATE!: ".plugin_dir_path(__DIR__) . '/templates/'.$template);
return plugin_dir_path(__DIR__) . '/templates/'.$template;
}
}
return $template;
......
......@@ -21,54 +21,46 @@
namespace wp_SexHackMe;
if(!class_exists('SexhackHlsPlayer')) {
class SexhackHlsPlayer
if(!class_exists('SH_Shortcodes')) {
class SH_Shortcodes
{
public function __construct()
{
sexhack_log('SexhackHlsPlayer() Instanced');
add_shortcode("sexhls", array( $this, "sexhls_shortcode"));
}
public static function init() {
$shortcodes = array(
'sexhls' => __CLASS__ . '::video_hls',
'sexvideo' => __CLASS__ . '::video_xr',
'sh_videoxr' => __CLASS__ . '::video_xr',
'sh_videohls' => __CLASS__ . '::video_hls',
);
foreach( $shortcodes as $shortcode_tag => $shortcode_func ) {
add_shortcode( $shortcode_tag, $shortcode_func );
}
public function addPlayer($vurl, $posters="")
}
public static function video_hls($attr, $cont)
{
$uid = uniqid('sexhls_');
$html = '<video id="'.$uid.'" style="width: 100%; height: 100%;" controls poster="'.$posters.'"></video>'."\n";
$html .= '<script language="javascript">'."\n";
$html .= '$(window).on(\'load\', function() {'."\n";
$html .= ' SexHLSPlayer(\''.$vurl.'\', \''.$uid.'\');'."\n";
$html .= ' $(\'#'.$uid.'\').on(\'click\', function(){this.paused?this.play():this.pause();});'."\n";
$html .= ' Mousetrap(document.getElementById(\''.$uid.'\')).bind(\'space\', function(e, combo) { SexHLSplayPause(\''.$uid.'\'); });'."\n";
$html .= ' Mousetrap(document.getElementById(\''.$uid.'\')).bind(\'up\', function(e, combo) { SexHLSvolumeUp(\''.$uid.'\'); });'."\n";
$html .= ' Mousetrap(document.getElementById(\''.$uid.'\')).bind(\'down\', function(e, combo) { SexHLSvolumeDown(\''.$uid.'\'); });'."\n";
$html .= ' Mousetrap(document.getElementById(\''.$uid.'\')).bind(\'right\', function(e, combo) { SexHLSseekRight(\''.$uid.'\'); });'."\n";
$html .= ' Mousetrap(document.getElementById(\''.$uid.'\')).bind(\'left\', function(e, combo) { SexHLSseekLeft(\''.$uid.'\'); });'."\n";
$html .= ' Mousetrap(document.getElementById(\''.$uid.'\')).bind(\'f\', function(e, combo) { SexHLSvidFullscreen(\''.$uid.'\'); });'."\n";
$html .= '});'."\n";
$html .= '</script>'."\n";
return $html;
extract( shortcode_atts(array(
"url" => '',
"posters" => '',
), $attr));
return "<div class='sexhls_video'>" . sh_hls_player($url, $posters) . "</div>";
}
public function sexhls_shortcode($attr, $cont)
public static function video_xr($attr, $cont)
{
extract( shortcode_atts(array(
"url" => '',
"posters" => '',
), $attr));
return "<div class='sexhls_video'>" . $this->addPlayer($url, $posters) . "</div>";
return "<div class='sexvideo_videojs'>" . sh_xr_player($url, $posters) . "</div>";
}
}
}
}
}
$SEXHACK_SECTION = array(
'class' => 'SexhackHlsPlayer',
'description' => 'Add HLS Video Player for progressive and live streaming support',
'name' => 'sexhackme_hls_player'
);
?>
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
namespace wp_SexHackMe;
if(!class_exists('SH_VideoPlayer')) {
class SH_VideoPlayer
{
public static function addPlayer($player_type='hls', $vurl='', $posters="", $projection='180_LR')
{
$html = false;
switch($player_type)
{
case 'hls':
$html = sh_get_template("videoplayer/hls.php", array('vurl' => $vurl, 'posters' => $posters ));
sexhack_log($html);
break;
case 'xr':
$html = sh_get_template("videoplayer/xr.php", array('vurl' => $vurl, 'posters' => $posters, 'projection' => $projection));
break;
}
return $html;
}
}
}
?>
......@@ -37,6 +37,27 @@ if(!function_exists('sexhack_log')){
}
function sh_get_template($tmpl, $args=array())
{
foreach($args as $var => $data) $$var = $data;
if(file_exists(SH_PLUGIN_DIR_PATH . 'templates/' . $tmpl))
return include_once SH_PLUGIN_DIR_PATH . 'templates/' . $tmpl;
return false;
}
function sh_hls_player($video_url, $posters='')
{
echo SH_VideoPlayer::addPlayer('hls', $video_url, $posters);
}
function sh_xr_player($video_url, $posters='', $projection='180_LR')
{
echo SH_VideoPlayer::addPlayer('xr', $video_url, $posters, $projection);
}
function debug_rewrite_rules($matchonly=false)
{
$matchonly=true;
......@@ -261,4 +282,10 @@ function html2text($html)
return $plaintext;
}
function checkbox($res)
{
if($res=="1") return "checked";
}
?>
This diff is collapsed.
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
?>
<div class="wrap">
<h2>SexHackMe Plugin Settings</h2>
<form method="post" action="/wp-admin/options.php">
<?php settings_fields( 'sexhackme-settings' ); ?>
<?php do_settings_sections( 'sexhackme-settings' ); ?>
<table class="form-table">
<?php foreach($this->SECTIONS as $section) { ?>
<tr align="top">
<th scope="row"><?php echo $section['description'];?></th>
<td>
<input type="checkbox" name="<?php echo $section['name'];?>" value="1" <?php echo wp_SexHackMe\checkbox(get_option( $section['name'] )); ?>/>
<br>
<?php
if(array_key_exists('require-page', $section) && ($section['require-page']))
{
$reqps = array();
if(is_string($section['require-page']))
{
$reqtitle="Select the base plugin module page";
$reqpages=get_posts(array('post_type' => $section['require-page'], 'parent' => 0));
$reqps[] = array('title' => $reqtitle, 'pages' => $reqpages, 'option' => $section['name']."-page");
} elseif(is_array($section['require-page'])) {
$i=0;
foreach($section['require-page'] as $rpage) {
if(array_key_exists('post_type', $rpage)) {
$reqpsa = array('title' => 'Select Page', 'option' => $section['name']."-page$i",
'pages' => get_posts(array('post_type' => $rpage['post_type'], 'parent' => 0)));
if(array_key_exists('option', $rpage)) $reqpsa['option'] = $rpage['option'];
if(array_key_exists('title', $rpage)) $reqpsa['title'] = $rpage['title'];
$reqps[] = $reqpsa;
}
$i++;
}
} else {
$reqtitle="Select the base plugin module page";
$reqpages=get_pages();
$reqps[] = array('title' => $reqtitle, 'pages' => $reqpages, 'option' => $section['name']."-page");
}
foreach($reqps as $reqarr) {
?>
<select id="<?php echo $reqarr['option'];?>" name="<?php echo $reqarr['option']; ?>" class="widefat">
<option value="-1"><?php esc_html_e( 'Choose...', 'paid-member-subscriptions' ) ?></option>
<?php
$opt=get_option($reqarr['option']);
foreach( $reqarr['pages'] as $page ) {
echo '<option value="' . esc_attr( $page->ID ) . '"';
if ($opt == $page->ID) { echo "selected";}
echo '>' . esc_html( $page->post_title ) . ' ( ID: ' . esc_attr( $page->ID ) . ')' . '</option>';
} ?>
</select>
<p class="description"><?php echo $reqarr['title']; ?></p>
<?php } ?>
<?php } ?>
</td>
</tr>
<?php } ?>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
$uid = uniqid('sexhls_');
?>
<video id="<?php echo $uid; ?>" style="width: 100%; height: 100%;" controls poster="<?php echo $posters; ?>"></video>
<script language="javascript">
$(window).on('load', function() {
SexHLSPlayer('<?php echo $vurl; ?>', '<?php echo $uid; ?>');
$('#<?php echo $uid; ?>').on('click', function(){this.paused?this.play():this.pause();});
Mousetrap(document.getElementById('<?php echo $uid; ?>')).bind('space', function(e, combo) { SexHLSplayPause('<?php echo $uid; ?>'); });
Mousetrap(document.getElementById('<?php echo $uid; ?>')).bind('up', function(e, combo) { SexHLSvolumeUp('<?php echo $uid; ?>'); });
Mousetrap(document.getElementById('<?php echo $uid; ?>')).bind('down', function(e, combo) { SexHLSvolumeDown('<?php echo $uid; ?>'); });
Mousetrap(document.getElementById('<?php echo $uid; ?>')).bind('right', function(e, combo) { SexHLSseekRight('<?php echo $uid; ?>'); });
Mousetrap(document.getElementById('<?php echo $uid; ?>')).bind('left', function(e, combo) { SexHLSseekLeft('<?php echo $uid; ?>'); });
Mousetrap(document.getElementById('<?php echo $uid; ?>')).bind('f', function(e, combo) { SexHLSvidFullscreen('<?php echo $uid; ?>'); });
});
</script>
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
$uid = uniqid('sexvideo_');
?>
<video id='<?php echo $uid; ?>' class='video-js vjs-default-skin vjs-2-1 vjs-big-play-centered' style='width: 100%; height: 100%;' controls poster='<?php echo $posters; ?>'>
</video>
<script language='javascript'>
$(window).on('load', function() {
var player = videojs('<?php echo $uid; ?>', {
html5: {
vhs: {
overrideNative: !videojs.browser.IS_SAFARI
},
nativeAudioTracks: false,
nativeVideoTracks: false
}});
player.src({ src: '<?php echo $vurl; ?>', type: 'application/x-mpegURL'});
player.xr();
});
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment