ok.. this seems to be a little bit complicated on read.. the final problem is:
$item->text()->blocks() throws the error, when calling a site with a custom tag, which uses a custom snippet, that i made..
long story:
i could not upgrade to kirby 3.5 yet.. but will in near future.. (my used template gets an upgrade soon)
i am using kirby3-feed and kirby3-video with a custom snippet for videos (i need a player with captions and quality selector - in my case i use plyr.io):
since i'm not a real- but more a hobby-coder, this code is for sure not good code.. but it worked. =)
<?php
/*
pattern for video files:
base-filename-480.m4v
base-filename-576.m4v
base-filename-720.m4v
base-filename-1080.m4v
pattern for vtt subtitle files (use two digit ISO-639-1 codes!):
base-filename-de.vtt
base-filename-en.vtt
base-filename-fr.vtt
*/
$afterlasthyphen = "/[^-]*$/";
$qualitypattern = "/(\d{3,4})$/";
$cutname = preg_replace($qualitypattern, '', $video->name()) ;
$posterimage = Html::tag('img', null, ['src' => $posterurl, 'alt' => $alt]);
if ($video->siblings()->filterBy('filename', '^=', $cutname)->count() > 1) {
foreach($video->siblings()->filterBy('filename', '^=', $cutname) as $file) {
preg_match($qualitypattern, $file->name(), $vidres);
if ( (!empty($vidres[0])) AND ($file->extension() == $video->extension()) ){
$videsourcetag .= Html::tag('source', null, ['src' => $file->url(), 'type' => $mime, 'size' => $vidres[0]]);
} else {
$videsourcetag = Html::tag('source', null, ['src' => $videourl, 'type' => $mime]);
}
}
} else {
$videsourcetag = Html::tag('source', null, ['src' => $videourl, 'type' => $mime]);
}
foreach($video->siblings()->filterBy('filename', '^=', $cutname) as $file) {
if ( $file->extension() == "vtt" ) {
preg_match($afterlasthyphen, $file->name(), $langsrc);
$langcode = $langsrc[0];
$videsourcetag .= Html::tag('track', null, ['kind' => "captions", 'label' => Locale::getDisplayLanguage($langcode, $langcode), 'srclang' => $langcode, 'src' => $file->url(), 'default' => ""]);
}
}
$videsourcetag .= Html::tag('a', [$posterimage], ['href' => $videourl]);
$vidtag = Html::tag('video', [$videsourcetag], ['poster' => $posterurl, 'width' => $width, 'height' => $height, 'controls' => $controls, 'preload' => $preload, 'class' => $vidclass]);
if($caption) {
$cap = Html::tag('figcaption', [$caption]);
} else {
$cap = null;
}
$vidtag .= $cap;
$player = Html::tag('figure', [$vidtag], ['class' => $class]);
?>
<!-- Embed plyr Player - CSS -->
<?= css([$kirby->url('assets') . '/css/plyr.css']) ?>
<!-- / Embed plyr Player - CSS -->
<!-- Video Player -->
<?= $player ?>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "VideoObject",
"name": "<?= $title ?>",
"description": "<?= $caption ?>",
"thumbnailUrl": "<?= $posterurl ?>",
"contentUrl": "<?= $videourl ?>",
"uploadDate": "<?= $modified ?>"
}
</script>
<!-- / Video Player -->
<!-- Embed plyr Player - JS -->
<?= js($kirby->url('assets') . '/js/plyr.min.js') ?>
<script>
// Change the second argument to your options:
// https://github.com/sampotts/plyr/#options
const players = Array.from(document.querySelectorAll('video')).map(p => new Plyr(p, {
controls: [
'play-large', // The large play button in the center
// 'restart', // Restart playback
// 'rewind', // Rewind by the seek time (default 10 seconds)
'play', // Play/pause playback
// 'fast-forward', // Fast forward by the seek time (default 10 seconds)
'progress', // The progress bar and scrubber for playback and buffering
'current-time', // The current time of playback
'duration', // The full duration of the media
'mute', // Toggle mute
'volume', // Volume control
'captions', // Toggle captions
'settings', // Settings menu
// 'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
'fullscreen', // Toggle fullscreen
],
settings: [
'captions',
'quality',
'loop',
]
}));
// Expose player
//window.player = player;
</script>
<!-- / Embed plyr Player - JS -->
now, when using kirby3-feed, to generate a RSS-Feed by parsing my journal entries, i get this error while trying to parse Block fields "$item->text()->blocks()" that include the kirbytag for the video (the tag calls the snippet above):
ok.. this seems to be a little bit complicated on read.. the final problem is:
$item->text()->blocks()
throws the error, when calling a site with a custom tag, which uses a custom snippet, that i made..long story: i could not upgrade to kirby 3.5 yet.. but will in near future.. (my used template gets an upgrade soon)
i am using kirby3-feed and kirby3-video with a custom snippet for videos (i need a player with captions and quality selector - in my case i use plyr.io):
since i'm not a real- but more a hobby-coder, this code is for sure not good code.. but it worked. =)
now, when using kirby3-feed, to generate a RSS-Feed by parsing my journal entries, i get this error while trying to parse Block fields "
$item->text()->blocks()
" that include the kirbytag for the video (the tag calls the snippet above):any idea on that?