aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/plyr.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index b3e9cfdf..9a7e78c3 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -1930,6 +1930,35 @@
}
}
+ // Add common function to retrieve media source
+ function _source(source) {
+ // If not null or undefined, parse it
+ if(typeof source !== 'undefined') {
+ _updateSource(source);
+ return;
+ }
+
+ // Return the current source
+ var url;
+ switch(plyr.type) {
+ case 'youtube':
+ url = plyr.embed.getVideoUrl();
+ break;
+
+ case 'vimeo':
+ plyr.embed.api('getVideoUrl', function (value) {
+ url = value;
+ });
+ break;
+
+ default:
+ url = plyr.media.currentSrc;
+ break;
+ }
+
+ return url || '';
+ }
+
// Update source
// Sources are not checked for support so be careful
function _updateSource(source) {
@@ -2394,7 +2423,7 @@
rewind: _rewind,
forward: _forward,
seek: _seek,
- source: _updateSource,
+ source: _source,
poster: _updatePoster,
setVolume: _setVolume,
togglePlay: _togglePlay,