diff options
author | Sam Potts <me@sampotts.me> | 2016-01-14 09:53:58 +1100 |
---|---|---|
committer | Sam Potts <me@sampotts.me> | 2016-01-14 09:53:58 +1100 |
commit | cce7e9932e7d851ea85c82127bbeff844d8d308a (patch) | |
tree | b8e3ad7bb00e29ab8a9114f51275f4a003b8e299 /src | |
parent | e6c30ec137d4bcec69044114f7868461c7c374f0 (diff) | |
download | plyr-cce7e9932e7d851ea85c82127bbeff844d8d308a.tar.lz plyr-cce7e9932e7d851ea85c82127bbeff844d8d308a.tar.xz plyr-cce7e9932e7d851ea85c82127bbeff844d8d308a.zip |
Merge for new source api changes
Diffstat (limited to 'src')
-rw-r--r-- | src/js/plyr.js | 31 |
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, |