aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuru Prasad Srinivasa <gurupras@buffalo.edu>2016-01-13 14:58:01 -0500
committerGuru Prasad Srinivasa <gurupras@buffalo.edu>2016-01-13 17:19:19 -0500
commit533bd173b2d011a496a6d486a699296425ead7a7 (patch)
tree83c6b73c4f48298134886bb6a1a3494bd083c850 /src
parent533af96c4f99da01f5157e02859d667dac92519f (diff)
downloadplyr-533bd173b2d011a496a6d486a699296425ead7a7.tar.lz
plyr-533bd173b2d011a496a6d486a699296425ead7a7.tar.xz
plyr-533bd173b2d011a496a6d486a699296425ead7a7.zip
Updated API function 'plyr.source()' to get media source
Currently, there is no simple way of acquiring media source. This commit updates the 'source' API function to allow developers to acquire the video source regardless of whether the video is a youtube-embed or HTML5 video. Future embeds just need their respective URL fetching code added to this common function.
Diffstat (limited to 'src')
-rw-r--r--src/js/plyr.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 44f17290..638deaad 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -1716,6 +1716,27 @@
}
}
+ // Add common function to retrieve media source
+ function _source(args) {
+ // If not null or undefined, parse it
+ if(args !== null && args !== undefined) {
+ return _parseSource(args);
+ }
+
+ // Return the current source
+
+ // The following lines inside if/else may fail.
+ // Not sure whether to bubble exception up or
+ // return a default value or log to console.
+ if(player.type === "youtube") {
+ return player.embed.getVideoUrl();
+ }
+ else {
+ return player.media.currentSrc;
+ }
+ }
+
+
// Update poster
function _updatePoster(source) {
if (player.type === 'video') {
@@ -1997,7 +2018,7 @@
rewind: _rewind,
forward: _forward,
seek: _seek,
- source: _parseSource,
+ source: _source,
poster: _updatePoster,
setVolume: _setVolume,
togglePlay: _togglePlay,
@@ -2088,4 +2109,4 @@
return players;
};
-}(this.plyr = this.plyr || {})); \ No newline at end of file
+}(this.plyr = this.plyr || {}));