-
Notifications
You must be signed in to change notification settings - Fork 6
chapters/thumbnails support added to subtitle feature #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jojoob
wants to merge
3
commits into
lucisgit:master
Choose a base branch
from
sudile:dev-tracks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise would be better as "->out(false)" |
||
'label' => $label); | ||
} | ||
} | ||
$playlistitem['tracks'] = $tracks; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better as "->out(false)" to prevent the URLs being escaped which causes issues if the URL contains a query string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the URL will be embedded in the Javascript code we need the unescaped version. Otherwise jwplayer could not parse the html escaped URL.
You dropped the subtitle feature by adding the if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my point.
By default the out method for a moodle_url has escaped set to true, so this needs to specify false to ensure we're using the unescaped version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which if statement are you referring to?
The only one there appears to check $options['subtitles'] is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood you. Maybe I should not work just from my smartphone. You are right and I will change this as soon I'm back in office.