diff --git a/lib.php b/lib.php index 1baec4b..9076862 100644 --- a/lib.php +++ b/lib.php @@ -117,9 +117,16 @@ class filter_jwplayer_media extends core_media_player { * @param int $height Optional height; 0 to use default * @param array $options Options array * subtitles - * use 'subtitles' key with an array of subtitle track files + * use 'subtitles' key with an array of moodle_url to subtitle track files * in vtt or srt format indexed by label name. - * Example: $options['subtitles']['English'] = http://example.com/english.vtt + * use 'chapters' or 'thumbnail' index for adding chapters/thumbnails + * to the video. see: + * * http://support.jwplayer.com/customer/portal/articles/1407438-adding-closed-captions + * * http://support.jwplayer.com/customer/portal/articles/1407454-adding-chapter-markers + * * http://support.jwplayer.com/customer/portal/articles/1407439-adding-preview-thumbnails + * Examples: + * $options['subtitles']['English'] = new moodle_url('english.vtt') + * $options['subtitles']['chapters'] = new moodle_url('chapters.vtt') * @return string HTML code for embed */ public function embed($urls, $name, $width, $height, $options) { @@ -161,9 +168,15 @@ public function embed($urls, $name, $width, $height, $options) { if (isset($options['subtitles'])) { $tracks = array(); foreach ($options['subtitles'] as $label => $subtitlefileurl) { - $tracks[] = array( - 'file' => $subtitlefileurl->out(), - 'label' => $label); + if ($label == 'chapters' || $label == 'thumbnails') { + $tracks[] = array( + 'file' => $subtitlefileurl->out(), + 'kind' => $label); + } else { + $tracks[] = array( + 'file' => $subtitlefileurl->out(), + 'label' => $label); + } } $playlistitem['tracks'] = $tracks; }