Changes

Jump to: navigation, search

External Playlist

1,183 bytes added, 11:48, 24 December 2012
no edit summary
If you want to show the playlist on the page you can use external playlist Если вы хотите показывать плейлист на странице, вы можете использовать внешний плейлист (a playlist which can be placed anywhere on the page using standart плейлист, который можно разместить в любом месте на странице, используя стандартный html). It is useful for fast switching between channelsУдобно для быстрого переключения между каналами, for exampleнапример.
You can see an example of external playlist hereПример внешнего плейлиста вы можете посмотреть здесь: http://torrentstream.org/test/test_playlist.html
First, you need to load our Сначала вам необходимо загрузить нашу библиотеку javascript library:
<tt><script type="text/javascript" src="http://static.torrentstream.org/jsapi/js/lib/ts/core.js"></script>
<script type="text/javascript" src="http://static.torrentstream.org/jsapi/js/lib/ts/player.js"></script></tt>
We update Мы периодически обновляем библиотеку javascript library frequenly, so we recommend to load поэтому рекомендуем загружать javascript files from our serversфайлы с наших серверов, not to store them on your serversа не хранить их на ваших серверах.
Then you need to create the player objectЗатем вам необходимо создать плеер:
<tt>player = new TorrentStream.Player(document.getElementById("player"), {
useInternalControls: true,
}
});</tt>
Player object constructor takes two parametersКонструктор плеера принимает два параметра: <tt>TorrentStream.Player(container, config)</tt>*''container'' - html elementэлемент, which will be used as player containerкоторый будет использован как контейнер плеера*''config'' - an object with optional configuration paramsобъект с дополнительными параметрами конфигурации
In this example we use such optionsВ данном примере мы используем следующие опции:*''useInternalControls'': show controls inside plugin's windowпоказывать панель управления внутри окна плагина*''onLoad'': this function is called when the plugin has finished loading and is ready for usageэта функция вызывается, когда плагин закончил загрузку и готов к использованию
In the При возврате ''onLoad'' callback we load five channels in the playlistмы загружаем пять каналов в плейлист, using player's method используя метод плеера loadTorrent.
If the plugin is not installed an exception Если плагин не установлен, выбрасывается исключение "plugin_not_installed" is thrown. You can catch this exception and show some message to the user, for exampleВы можете перехватить это исключение и показать какое-нибудь сообщение пользователю. Например, this wayтак:
<tt>try {
player = new TorrentStream.Player(...);
catch(e) {
if(e == "plugin_not_installed") {
document.getElementById("message").innerHTML = "Plugin not installedПлагин не установлен. Install Установить <a href=\"http://dl.torrentstream.org/products/torrentstream-full/win/latest\" target=\"_blank\">hereздесь</a>";
}
else {
}</tt>
Then create an external playlistЗатем создайте внешний плеер:
<nowiki><div class="playlist-item" onclick="playChannel(0);">ТНТ</div>
<div class="playlist-item" onclick="playChannel(1);">Первый канал</div>
<div class="playlist-item" onclick="playChannel(4);">СТС</div></nowiki>
Clicking on playlist items is handled by function Нажатие на пунктах плейлиста производится функцией playChannel():
<tt>function playChannel(playlistIndex) {
if(!player) {
}</tt>
This functions checks whether the player object exists and then call Эта функция проверяет, существует ли плеер, а потом вызывает метод play() method which takes zero-based playlist item index as first argument, который принимает первый пункт плейлиста как первый аргумент.

Navigation menu