|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>External WebVTT example</title> |
| 6 | + <script class="code" src="../../contrib/akamai/controlbar/ControlBar.js"></script> |
| 7 | + |
| 8 | + <script src="../../dist/modern/umd/dash.all.debug.js"></script> |
| 9 | + |
| 10 | + <!-- Bootstrap core CSS --> |
| 11 | + <link href="../lib/bootstrap/bootstrap.min.css" rel="stylesheet"> |
| 12 | + <link href="../lib/main.css" rel="stylesheet"> |
| 13 | + <link rel="stylesheet" href="../../contrib/akamai/controlbar/controlbar.css"> |
| 14 | + |
| 15 | + <style> |
| 16 | + video { |
| 17 | + width: 100%; |
| 18 | + } |
| 19 | + |
| 20 | + .dash-video-player { |
| 21 | + position: relative; /* This position relative is needed to position the menus */ |
| 22 | + margin: 0 auto; |
| 23 | + line-height: 1.0; |
| 24 | + } |
| 25 | + </style> |
| 26 | + |
| 27 | + <script class="code"> |
| 28 | + |
| 29 | + function init() { |
| 30 | + var url = 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd', |
| 31 | + video = document.querySelector('video'), |
| 32 | + controlbar, |
| 33 | + player; |
| 34 | + var externalSubtitle = new dashjs.ExternalSubtitle({ |
| 35 | + id: 'external_1', |
| 36 | + url: 'https://reference.dashif.org/other/content/webvtt/external-subtitle.vtt', |
| 37 | + mimeType: 'text/vtt', |
| 38 | + language: 'en', |
| 39 | + bandwidth: 256 |
| 40 | + }); |
| 41 | + var externalSubtitleTwo = new dashjs.ExternalSubtitle({ |
| 42 | + id: 'external_2', |
| 43 | + url: 'https://reference.dashif.org/other/content/webvtt/external-subtitle-2.vtt', |
| 44 | + mimeType: 'text/vtt', |
| 45 | + language: 'de', |
| 46 | + bandwidth: 256 |
| 47 | + }); |
| 48 | + |
| 49 | + player = dashjs.MediaPlayer().create(); |
| 50 | + player.initialize(video, null, true); |
| 51 | + controlbar = new ControlBar(player); /* Checkout ControlBar.js for more info on how to target/add text tracks to UI */ |
| 52 | + controlbar.initialize(); |
| 53 | + player.addExternalSubtitle(externalSubtitle); |
| 54 | + player.addExternalSubtitle(externalSubtitleTwo); |
| 55 | + player.attachSource(url); |
| 56 | + } |
| 57 | + </script> |
| 58 | +</head> |
| 59 | +<body> |
| 60 | + |
| 61 | +<main> |
| 62 | + <div class="container py-4"> |
| 63 | + <header class="pb-3 mb-4 border-bottom"> |
| 64 | + <img class="" |
| 65 | + src="../lib/img/dashjs-logo.png" |
| 66 | + width="200"> |
| 67 | + </header> |
| 68 | + <div class="row"> |
| 69 | + <div class="col-md-4"> |
| 70 | + <div class="h-100 p-5 bg-light border rounded-3"> |
| 71 | + <h3>WebVTT Dash Demo</h3> |
| 72 | + <p>This example shows how to use the dash.js API to add an external WebVTT file that is not part of |
| 73 | + the DASH manifest. </p> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + <div class="col-md-8"> |
| 77 | + <div class="dash-video-player code"> |
| 78 | + <div class="videoContainer" id="videoContainer"> |
| 79 | + <video preload="auto" autoplay></video> |
| 80 | + <div id="videoController" class="video-controller unselectable"> |
| 81 | + <div id="playPauseBtn" class="btn-play-pause" title="Play/Pause"> |
| 82 | + <span id="iconPlayPause" class="icon-play"></span> |
| 83 | + </div> |
| 84 | + <span id="videoTime" class="time-display">00:00:00</span> |
| 85 | + <div id="fullscreenBtn" class="btn-fullscreen control-icon-layout" title="Fullscreen"> |
| 86 | + <span class="icon-fullscreen-enter"></span> |
| 87 | + </div> |
| 88 | + <div id="bitrateListBtn" class="control-icon-layout" title="Bitrate List"> |
| 89 | + <span class="icon-bitrate"></span> |
| 90 | + </div> |
| 91 | + <input type="range" id="volumebar" class="volumebar" value="1" min="0" max="1" step=".01"/> |
| 92 | + <div id="muteBtn" class="btn-mute control-icon-layout" title="Mute"> |
| 93 | + <span id="iconMute" class="icon-mute-off"></span> |
| 94 | + </div> |
| 95 | + <div id="trackSwitchBtn" class="control-icon-layout" title="A/V Tracks"> |
| 96 | + <span class="icon-tracks"></span> |
| 97 | + </div> |
| 98 | + <div id="captionBtn" class="btn-caption control-icon-layout" title="Closed Caption"> |
| 99 | + <span class="icon-caption"></span> |
| 100 | + </div> |
| 101 | + <span id="videoDuration" class="duration-display">00:00:00</span> |
| 102 | + <div class="seekContainer"> |
| 103 | + <div id="seekbar" class="seekbar seekbar-complete"> |
| 104 | + <div id="seekbar-buffer" class="seekbar seekbar-buffer"></div> |
| 105 | + <div id="seekbar-play" class="seekbar seekbar-play"></div> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + </div> |
| 112 | + </div> |
| 113 | + <div class="row"> |
| 114 | + <div class="col-md-12"> |
| 115 | + <div id="code-output"></div> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | + <footer class="pt-3 mt-4 text-muted border-top"> |
| 119 | + © DASH-IF |
| 120 | + </footer> |
| 121 | + </div> |
| 122 | +</main> |
| 123 | + |
| 124 | + |
| 125 | +<script> |
| 126 | + document.addEventListener('DOMContentLoaded', function () { |
| 127 | + init(); |
| 128 | + }); |
| 129 | +</script> |
| 130 | +<script src="../highlighter.js"></script> |
| 131 | +</body> |
| 132 | +</html> |
0 commit comments