negromate/web/static/js/videojs-playlist/docs/api/play-item.js.html

107 lines
2.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: play-item.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: play-item.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import {setup} from './auto-advance.js';
/**
* Removes all remote text tracks from a player.
*
* @param {Player} player
* The player to clear tracks on
*/
const clearTracks = (player) => {
const tracks = player.remoteTextTracks();
let i = tracks &amp;&amp; tracks.length || 0;
// This uses a `while` loop rather than `forEach` because the
// `TextTrackList` object is a live DOM list (not an array).
while (i--) {
player.removeRemoteTextTrack(tracks[i]);
}
};
/**
* Plays an item on a player's playlist.
*
* @param {Player} player
* The player to play the item on
*
* @param {Object} item
* A source from the playlist.
*
* @return {Player}
* The player that is now playing the item
*/
const playItem = (player, item) => {
const replay = !player.paused() || player.ended();
player.trigger('beforeplaylistitem', item);
player.poster(item.poster || '');
player.src(item.sources);
clearTracks(player);
player.ready(() => {
(item.textTracks || []).forEach(player.addRemoteTextTrack.bind(player));
player.trigger('playlistitem', item);
if (replay) {
player.play();
}
setup(player, player.playlist.autoadvance_.delay);
});
return player;
};
export default playItem;
export {clearTracks};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Events</h3><ul><li><a href="global.html#event:playlistsorted">playlistsorted</a></li></ul><h3>Global</h3><ul><li><a href="global.html#clearTracks">clearTracks</a></li><li><a href="global.html#playItem">playItem</a></li><li><a href="global.html#plugin">plugin</a></li><li><a href="global.html#reset">reset</a></li><li><a href="global.html#setReset_">setReset_</a></li><li><a href="global.html#setup">setup</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Jan 26 2018 12:37:44 GMT-0500 (EST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>