For more complex configurations, you can use the window.webtor array pattern. This allows you to define the player configuration in a script block before the SDK is loaded. This method is useful for passing complex objects like subtitle arrays or specific player settings.
- Create a container element (e.g., a
<div>) with a specific id and the class webtor. - Push a configuration object to
window.webtor. - Load the SDK script.
<div id="player" class="webtor" />
<script>
window.webtor = window.webtor || [];
window.webtor.push({
id: 'player',
magnet: 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F',
poster: 'https://via.placeholder.com/150/0000FF/808080',
subtitles: [
{
srclang: 'en',
label: 'test',
src: 'https://raw.githubusercontent.com/andreyvit/subtitle-tools/master/sample.srt',
default: true,
}
],
lang: 'en',
});
</script>
<script src="https://cdn.jsdelivr.net/npm/@webtor/embed-sdk-js/dist/index.min.js" charset="utf-8" async></script>