aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Potts <me@sampotts.me>2016-01-14 09:53:58 +1100
committerSam Potts <me@sampotts.me>2016-01-14 09:53:58 +1100
commitcce7e9932e7d851ea85c82127bbeff844d8d308a (patch)
treeb8e3ad7bb00e29ab8a9114f51275f4a003b8e299
parente6c30ec137d4bcec69044114f7868461c7c374f0 (diff)
downloadplyr-cce7e9932e7d851ea85c82127bbeff844d8d308a.tar.lz
plyr-cce7e9932e7d851ea85c82127bbeff844d8d308a.tar.xz
plyr-cce7e9932e7d851ea85c82127bbeff844d8d308a.zip
Merge for new source api changes
-rw-r--r--changelog.md1
-rw-r--r--readme.md7
-rw-r--r--src/js/plyr.js31
3 files changed, 34 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md
index 9eb7b009..2813e66b 100644
--- a/changelog.md
+++ b/changelog.md
@@ -12,6 +12,7 @@
- Better handling of mission controls (fixes #132)
- Retain classname on source change (fixes #120)
- Increased thumb size on seek (partially fixes #130)
+- Passing no argument to `source` api method, now returns current source
## v1.3.5
- Fixed bug with API use on basic supported browsers
diff --git a/readme.md b/readme.md
index 6fe7936d..03033538 100644
--- a/readme.md
+++ b/readme.md
@@ -444,7 +444,7 @@ Here's a list of the methods supported:
</tr>
<tr>
<td><code>source(...)</code></td>
- <td>Array or (null|undefined)</td>
+ <td>Array or undefined</td>
<td>
Get/Set the media source.
<br><br>
@@ -459,8 +459,8 @@ Here's a list of the methods supported:
<strong>YouTube</strong><br>
Currently this API method only accepts a YouTube ID when used with a YouTube player. I will add URL support soon, along with being able to swap between types (e.g. YouTube to Audio or Video and vice versa.)
<br><br>
- <strong> null or undefined </strong><br>
- Returns the current media source. Works for both native videos and embeds.
+ <strong>undefined</strong><br>
+ Returns the current media source url. Works for both native videos and embeds.
</td>
</tr>
<tr>
@@ -707,4 +707,3 @@ Also these links helped created Plyr:
## Copyright and License
[The MIT license](license.md).
-
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,