-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add demo page to load stream via query parameters
- Loading branch information
Showing
2 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Load with url parameters</title> | ||
|
||
<script src="../../dist/dash.all.debug.js"></script> | ||
|
||
<!-- Bootstrap core CSS --> | ||
<link href="../lib/bootstrap/bootstrap.min.css" rel="stylesheet"> | ||
<link href="../lib/main.css" rel="stylesheet"> | ||
|
||
<style> | ||
video { | ||
width: 640px; | ||
height: 360px; | ||
} | ||
</style> | ||
|
||
<script class="code"> | ||
|
||
function getUrlVars() { | ||
var vars = {}; | ||
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { | ||
vars[key] = value; | ||
}); | ||
return vars; | ||
} | ||
|
||
function init() { | ||
var video, | ||
player; | ||
var urlParameter = getUrlVars(); | ||
var item = { | ||
url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd', | ||
autoplay: true | ||
} | ||
|
||
if (urlParameter) { | ||
if (urlParameter.hasOwnProperty('url')) { | ||
item.url = urlParameter.url; | ||
} | ||
if (urlParameter.hasOwnProperty('autoplay')) { | ||
item.autoplay = (urlParameter.autoplay === 'true'); | ||
} | ||
} | ||
|
||
video = document.querySelector('video'); | ||
player = dashjs.MediaPlayer().create(); | ||
player.initialize(video, item.url, item.autoplay); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<main> | ||
<div class="container py-4"> | ||
<header class="pb-3 mb-4 border-bottom"> | ||
<img class="" | ||
src="../lib/img/dashjs-logo.png" | ||
width="200"> | ||
</header> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="h-100 p-5 bg-light border rounded-3"> | ||
<h3>Load with url parameters</h3> | ||
<p>A demo page that uses url query parameters to configure the playback. The supported paramaters | ||
are:</p> | ||
<table class="table"> | ||
<tr> | ||
<th>Parameter</th> | ||
<th>Description</th> | ||
<th>Default</th> | ||
</tr> | ||
<tr> | ||
<td>autoplay</td> | ||
<td>Enables autoplay. Set to "true" or "false"</td> | ||
<td>"true"</td> | ||
</tr> | ||
<tr> | ||
<td>url</td> | ||
<td>Specify MPD url</td> | ||
<td>https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd</td> | ||
</tr> | ||
</table> | ||
|
||
</div> | ||
</div> | ||
<div class="row margin-top-row"> | ||
<div class="col-md-8"> | ||
<video controls="true"></video> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div id="code-output"></div> | ||
</div> | ||
</div> | ||
<footer class="pt-3 mt-4 text-muted border-top"> | ||
© DASH-IF | ||
</footer> | ||
</div> | ||
</main> | ||
|
||
|
||
<script> | ||
document.addEventListener('DOMContentLoaded', function () { | ||
init(); | ||
}); | ||
</script> | ||
<script src="../highlighter.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters