Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow viewing of 360 videos nicely #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions admin/admin_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'zoomrotate' => get_boolean($_POST['vjs_zoomrotate']),
'thumbnails' => get_boolean($_POST['vjs_thumbnails']),
'watermark' => get_boolean($_POST['vjs_watermark']),
'vr' => get_boolean($_POST['vjs_vr']),
),
'player' => $_POST['vjs_player'],
'metadata' => get_boolean($_POST['vjs_metadata']),
Expand Down
6 changes: 6 additions & 0 deletions admin/admin_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ Refer to the <a href="https://github.com/xbgmsharp/piwigo-videojs/wiki" target="
<label><input type="radio" name="vjs_resolution" value="false" {if not $plugins.resolution}checked="checked"{/if}/> {'No'|@translate}</label>
<br/><small>{'RESOLUTION_DESC'|@translate}</small>
</li>
<li>
<label><span class="property">{'VR'|@translate} : </span></label>
<label><input type="radio" name="vjs_vr" value="true" {if $plugins.vr}checked="checked"{/if}/> {'Yes'|@translate}</label>
<label><input type="radio" name="vjs_vr" value="false" {if not $plugins.vr}checked="checked"{/if}/> {'No'|@translate}</label>
<br/><small>{'VR_DESC'|@translate}</small>
</li>
</ul>
</fieldset>
<p>
Expand Down
5 changes: 5 additions & 0 deletions include/exiftool.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@
$exif['sampling_rate'] = (string)$general['AudioSampleRate'];
}

if (isset($general['ProjectionType']))
{
$exif['projection'] = (string)$general['ProjectionType'];
}

?>
2 changes: 2 additions & 0 deletions language/en_UK/plugin.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
$lang['WATERMARK_DESC'] = 'Displays watermark over the video.';
$lang['RESOLUTION'] = 'Resolution';
$lang['RESOLUTION_DESC'] = 'Resolution switcher.';
$lang['VR'] = 'View 360 videos';
$lang['VR_DESC'] = '360 Videos viewing (works with v6 only).';

$lang['SYNC_ERRORS'] = 'Errors';
$lang['SYNC_WARNINGS'] = 'Warnings';
Expand Down
16 changes: 16 additions & 0 deletions main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,21 @@ function vjs_render_media($content, $picture)
}
}

/* VR Plugin */
$vr_plugin = isset($conf['vjs_conf']['plugins']['vr']) ? strbool($conf['vjs_conf']['plugins']['vr']) : false;
$vr = array();
if ($vr_plugin)
{
$filename = $picture['current']['path'];
@include(__DIR__."/include/function_dependencies.php");
$sync_options['exiftool'] = 'exiftool';
if (isset($sync_binaries['exiftool']) and $sync_binaries['exiftool']) { include(dirname(__FILE__).'/include/exiftool.php'); }
if (isset($exif['projection']))
{
$vr['projection'] = $exif['projection'];
}
}

// Generate HTML5 tags
// Why the data-setup attribute does not work if only one video
$options = "";
Expand Down Expand Up @@ -400,6 +415,7 @@ function vjs_render_media($content, $picture)
'zoomrotate' => $zoomrotate,
'watermark' => $watermark,
'videos' => $videos,
'vr' => $vr
)
);

Expand Down
6 changes: 5 additions & 1 deletion template/vjs-5-player.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ videojs("my_video_1", {}, function(){
});
</script>
{/literal}

{if not empty($vr) and not empty($vr.projection)}
{literal}
<b>Note:</b> This video is an {/literal}{$vr.projection}{literal} spherical video, but VideoJS 5 doesn't support the VR plugin.
{/literal}
{/if}
{if not empty($thumbnails)}
{literal}
<script>
Expand Down
17 changes: 16 additions & 1 deletion template/vjs-6-player.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{html_head}
<link href="{$VIDEOJS_PATH}video-js-6/video-js.min.css" rel="stylesheet">
<script src="{$VIDEOJS_PATH}video-js-6/video.min.js"></script>
{if not empty($vr)}
<script src="{$VIDEOJS_PATH}video-js-vr/videojs-vr.min.js"></script>
{/if}
{literal}
<style type="text/css">
#my_video_1 canvas {
left: 0px;
}
</style>
{/literal}
{/html_head}

{literal}
Expand All @@ -19,9 +29,14 @@
{literal}
<script type="text/javascript">
// Once the video is ready
videojs("my_video_1", {}, function(){
var player = videojs("my_video_1", {}, function(){
var my_video_volume = videojs('my_video_1');
my_video_volume.volume({/literal}{$volume}{literal});
});
{/literal}
{if not empty($vr)}
{literal}player.vr({projection: '{/literal}{$vr.projection}{literal}'});{/literal}
{/if}
{literal}
</script>
{/literal}
4 changes: 3 additions & 1 deletion template/vjs-7-player.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
<p>Video Playback Not Supported<br/>Your browser does not support the video tag.</p>
</video>
{/literal}

{if not empty($vr)}
{literal}<b>Note:</b>This video is a(n) {/literal}{$vr.projection}{literal} spherical video, but VR doesn't support VideoJS &lg;= 7.{/literal}
{/if}
3 changes: 3 additions & 0 deletions video-js-vr/lang/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
videojs.addLanguage('en', {
"Include your own strings in JSON files.": "Include your own strings in JSON files."
});
Loading