From 5a50e7a83757bb0b914e770b2e68bb012064397d Mon Sep 17 00:00:00 2001 From: Mark Boas Date: Mon, 19 Sep 2022 18:12:30 +0200 Subject: [PATCH] ha lite 2.0.18 and vimeo support --- wp-hyperaudio/hyperaudio-admin.php | 5 +++- wp-hyperaudio/hyperaudio.php | 11 ++++----- wp-hyperaudio/js/hyperaudio-lite.js | 36 ++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/wp-hyperaudio/hyperaudio-admin.php b/wp-hyperaudio/hyperaudio-admin.php index f8715be..a271b65 100644 --- a/wp-hyperaudio/hyperaudio-admin.php +++ b/wp-hyperaudio/hyperaudio-admin.php @@ -184,10 +184,12 @@ function hyperaudio_options_page()

-

When defining the source of your media using the src attribute you will need to use embed versions for YouTube and SoundCloud.

+

When defining the source of your media using the src attribute you will need to use embed versions of the URL for YouTube, Vimeo and SoundCloud.

For example:

https://www.youtube.com/embed/xLcsdc823dg

or

+

https://player.vimeo.com/video/749606407

+

or

https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/730479133&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true *

* Grab the snippet of code from the SoundCloud page containing the file you're interested in, clicking on Share and then Embed.

You can define various other attributes including:

@@ -195,6 +197,7 @@ function hyperaudio_options_page() + diff --git a/wp-hyperaudio/hyperaudio.php b/wp-hyperaudio/hyperaudio.php index e2c9bc8..d466fe8 100644 --- a/wp-hyperaudio/hyperaudio.php +++ b/wp-hyperaudio/hyperaudio.php @@ -3,7 +3,7 @@ * Plugin Name: Official Hyperaudio Plugin * Plugin URI: https://hyper.audio * Description: Hyperaudio Interactive Transcript Player -* Version: 1.0.1 +* Version: 1.0.11 * Author: Mark Boas * Author URI: http://hyper.audio **/ @@ -21,6 +21,7 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) // defaults $width = '100%'; + $height = '100%'; $transcriptHeight = '600px'; $mediaHeight = ''; //$fontfamily = '"Palatino Linotype", "Book Antiqua", Palatino, serif'; @@ -36,12 +37,12 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) if (isset($atts['src'])) $src = esc_html__($atts['src']); if (isset($atts['width'])) $width = $atts['width']; + if (isset($atts['height'])) $height = $atts['height']; if (isset($atts['transcript-height'])) $transcriptHeight = $atts['transcript-height']; if (isset($atts['media-height'])) $mediaHeight = $atts['media-height']; if (isset($atts['font-family'])) $fontfamily = $atts['font-family']; if (isset($atts['id'])) $transcriptid = $atts['id']; - if (isset($atts['captions'])) $captionsOn = $atts['captions']; if (isset($atts['caption-max'])) $captionMaxLength = $atts['caption-max']; if (isset($atts['caption-min'])) $captionMinLength = $atts['caption-min']; @@ -52,7 +53,6 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) if (isset($atts['show-active'])) $showActive = $atts['show-active']; - $transcript = preg_replace( "/\r|\n/", "", $transcript); $transcript = str_replace("
", "", $transcript); @@ -159,8 +159,9 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) } else { $o .= '
'; } + } elseif (strpos(strtolower($src), 'vimeo.com') !== false) { + $o .= ''; } elseif (strpos(strtolower($src), 'soundcloud.com') !== false) { - //$o .= ''; $o .= ''; } elseif (strpos(strtolower($src), '.mp3') !== false) { $o .= ''; @@ -176,8 +177,6 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) $o .=''; - // - $o .='
'.$transcript.'
A Hyperaudio Production
'; diff --git a/wp-hyperaudio/js/hyperaudio-lite.js b/wp-hyperaudio/js/hyperaudio-lite.js index 7b6c9e5..cb10a35 100644 --- a/wp-hyperaudio/js/hyperaudio-lite.js +++ b/wp-hyperaudio/js/hyperaudio-lite.js @@ -1,5 +1,5 @@ /*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */ -/*! Version 2.0.17 */ +/*! Version 2.0.18 */ 'use strict'; @@ -53,6 +53,35 @@ function soundcloudPlayer(instance) { } } +function vimeoPlayer(instance) { + const tag = document.createElement('script'); + + + const iframe = document.querySelector('iframe'); + this.player = new Vimeo.Player(iframe); + this.player.setCurrentTime(0) + this.player.ready().then(instance.checkPlayHead); + + this.getTime = () => { + return new Promise((resolve) => { + resolve(this.player.getCurrentTime()); + }); + } + + this.setTime = (seconds) => { + this.player.setCurrentTime(seconds); + } + + this.play = () => { + this.player.play(); + } + + this.pause = () => { + this.player.pause(); + } +} + + function youtubePlayer(instance) { const tag = document.createElement('script'); tag.id = 'iframe-demo'; @@ -105,7 +134,8 @@ function youtubePlayer(instance) { const hyperaudioPlayerOptions = { "native": nativePlayer, "soundcloud": soundcloudPlayer, - "youtube": youtubePlayer + "youtube": youtubePlayer, + "vimeo": vimeoPlayer } function hyperaudioPlayer(playerType, instance) { @@ -587,4 +617,4 @@ if (typeof module !== 'undefined' && module.exports) { module.exports = { HyperaudioLite }; } -//export default HyperaudioLite; \ No newline at end of file +//export default HyperaudioLite;
attributeexample valuefunction
width100%set the width of the transcript + media holder
height100%set the height of the media holder
transcript-height700pxset the height of the transcript itself
media-height640pxset the height of the audio or video
font-familyArial, Helvetica, sans-serif;set the font family of the transcript