Listener, volume change #4634
Unanswered
Zuldek1994822
asked this question in
Q&A
Replies: 2 comments 2 replies
-
The listener works below is an example. Are you working with doubles as specified in the documentation:
Also there is no event if you provide an invalid value or the same value as already set. For mute you can probably just compare to a value equal to 0. <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Listening to events example</title>
<script src="https://reference.dashif.org/dash.js/latest/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;
}
.btn {
margin-top: 3px;
}
#trace {
height: 500px;
margin-top: 20px;
font-size: 10px;
}
</style>
<script class="code">
var player, firstLoad = true;
function init() {
player = dashjs.MediaPlayer().create();
player.updateSettings({ 'debug': { 'logLevel': dashjs.Debug.LOG_LEVEL_NONE } });
}
function showEvent(e) {
log("Volume changed: " + e.type);
}
function log(msg) {
msg = msg.length > 90 ? msg.substring(0, 90) + "..." : msg;
var tracePanel = document.getElementById("trace");
tracePanel.innerHTML += msg + "\n";
tracePanel.scrollTop = tracePanel.scrollHeight;
console.log(msg);
}
function load(button) {
var url = "https://livesim2.dashif.org/livesim2/scte35_2/testpic_2s/Manifest.mpd";
if (!firstLoad) {
player.attachSource(url);
} else {
firstLoad = false;
button.value = "RELOAD PLAYER";
player.initialize(document.querySelector("video"), url, true);
player.on('playbackVolumeChanged', showEvent);
}
document.getElementById("trace").innerHTML = "";
}
function changeVolume(increase = false) {
const step = increase ? 0.1 : -0.1;
player.setVolume(player.getVolume() + step);
}
</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-6">
<video controls="true"></video>
<div>
<input type="button" value="Load" onclick="load(this)"/>
</div>
<div>
<input type="button" value="Increase Volume" onclick="changeVolume(true)"/>
</div>
<div>
<input type="button" value="Decrease Volume" onclick="changeVolume(false)"/>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-floating">
<textarea class="form-control" placeholder="Trapped events will be displayed here"
id="trace"></textarea>
<label for="trace">Event log</label>
</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> |
Beta Was this translation helpful? Give feedback.
0 replies
-
Maybe I'm wrong. When I read it in the documentation, there is a listener. Which is triggered when the first attempt failed to start the video with sound. Is there such a listener? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I change the volume through
this.dsh.setVolume(0-1);
this.v.volume = 0-1;
The listener does not want to work in any way, what's the matter here?
The second question is, is there a listener that is triggered by mute and unmut?
Beta Was this translation helpful? Give feedback.
All reactions