Merge pull request #140 from gurupras/gurupras-develop
Updated API function 'plyr.source()' to get media source
This commit is contained in:
commit
debdf112cc
10
readme.md
10
readme.md
@ -356,10 +356,10 @@ Here's a list of the methods supported:
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>source(...)</code></td>
|
<td><code>source(...)</code></td>
|
||||||
<td>String or Array</td>
|
<td>String or Array or (null|undefined)</td>
|
||||||
<td>
|
<td>
|
||||||
Set the media source.
|
Get/Set the media source.
|
||||||
<br><br>
|
<br><br>
|
||||||
<strong>string</strong><br>
|
<strong>string</strong><br>
|
||||||
<code>.source("/path/to/video.mp4")</code><br>
|
<code>.source("/path/to/video.mp4")</code><br>
|
||||||
This will set the <code>src</code> attribute on the <code>video</code> or <code>audio</code> element.
|
This will set the <code>src</code> attribute on the <code>video</code> or <code>audio</code> element.
|
||||||
@ -370,6 +370,9 @@ Here's a list of the methods supported:
|
|||||||
<br><br>
|
<br><br>
|
||||||
<strong>YouTube</strong><br>
|
<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.)
|
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.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -504,3 +507,4 @@ Also these links helped created Plyr:
|
|||||||
|
|
||||||
## Copyright and License
|
## Copyright and License
|
||||||
[The MIT license](license.md).
|
[The MIT license](license.md).
|
||||||
|
|
||||||
|
@ -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
|
// Update poster
|
||||||
function _updatePoster(source) {
|
function _updatePoster(source) {
|
||||||
if (player.type === 'video') {
|
if (player.type === 'video') {
|
||||||
@ -1997,7 +2018,7 @@
|
|||||||
rewind: _rewind,
|
rewind: _rewind,
|
||||||
forward: _forward,
|
forward: _forward,
|
||||||
seek: _seek,
|
seek: _seek,
|
||||||
source: _parseSource,
|
source: _source,
|
||||||
poster: _updatePoster,
|
poster: _updatePoster,
|
||||||
setVolume: _setVolume,
|
setVolume: _setVolume,
|
||||||
togglePlay: _togglePlay,
|
togglePlay: _togglePlay,
|
||||||
@ -2088,4 +2109,4 @@
|
|||||||
return players;
|
return players;
|
||||||
};
|
};
|
||||||
|
|
||||||
}(this.plyr = this.plyr || {}));
|
}(this.plyr = this.plyr || {}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user