fixed the play/pause functionality on videos
This commit is contained in:
parent
15999c6a84
commit
e5d3fdf322
5 changed files with 33 additions and 27 deletions
|
@ -1,4 +1,21 @@
|
|||
function playOrPause(video){
|
||||
const showFunctions = {
|
||||
addPlayPauseToVideo: function () {
|
||||
const that = this;
|
||||
const video = document.getElementById('video-asset');
|
||||
if (video) {
|
||||
// add event listener for click
|
||||
video.addEventListener('click', ()=> {
|
||||
that.playOrPause(video);
|
||||
});
|
||||
// add event listener for space bar
|
||||
document.body.onkeyup = (event) => {
|
||||
if (event.keyCode == 32) {
|
||||
that.playOrPause(video);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
playOrPause: function(video){
|
||||
if (video.paused == true) {
|
||||
video.play();
|
||||
}
|
||||
|
@ -6,18 +23,4 @@ function playOrPause(video){
|
|||
video.pause();
|
||||
}
|
||||
}
|
||||
|
||||
// if a video player is present, set the listeners
|
||||
const video = document.getElementById('video-player');
|
||||
if (video) {
|
||||
// add event listener for click
|
||||
video.addEventListener('click', ()=> {
|
||||
playOrPause(video);
|
||||
});
|
||||
// add event listener for space bar
|
||||
document.body.onkeyup = (event) => {
|
||||
if (event.keyCode == 32) {
|
||||
playOrPause(video);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -21,9 +21,9 @@
|
|||
<body id="show-body">
|
||||
<script src="/assets/js/generalFunctions.js"></script>
|
||||
<script src="/assets/js/navBarFunctions.js"></script>
|
||||
<script src="/assets/js/showFunctions.js"></script>
|
||||
{{> navBar}}
|
||||
{{{ body }}}
|
||||
<script src="/assets/js/showFunctions.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
{{ googleAnalytics }}
|
||||
</head>
|
||||
<body id="showlite-body">
|
||||
{{{ body }}}
|
||||
<script src="/assets/js/showFunctions.js"></script>
|
||||
{{{ body }}}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div id="asset-display-component">
|
||||
<div id="asset-status">
|
||||
<p id="searching-message" hidden="true">Sit tight, we're combing the LBRY blockchain for your asset!</p>
|
||||
<p id="searching-message" hidden="true">Sit tight, we're searching the LBRY blockchain for your asset!</p>
|
||||
<div id="failure-message" hidden="true">
|
||||
<p>Unfortunately, we couldn't download your asset from LBRY. You can help us out by sharing the below error message in the <a class="link--primary" href="https://discord.gg/YjYbwhS" target="_blank">LBRY discord</a>.</p>
|
||||
<i><p id="error-message"></p></i>
|
||||
|
@ -90,7 +90,6 @@
|
|||
console.log('xhr.readyState', xhr.readyState);
|
||||
}
|
||||
};
|
||||
// Initiate a multipart/form-data upload
|
||||
xhr.send();
|
||||
},
|
||||
getAsset: function(claimName, claimId) {
|
||||
|
@ -113,7 +112,6 @@
|
|||
console.log('xhr.readyState', xhr.readyState);
|
||||
}
|
||||
};
|
||||
// Initiate a multipart/form-data upload
|
||||
xhr.send();
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,3 +4,8 @@
|
|||
<!--fallback-->
|
||||
Your browser does not support the <code>video</code> element.
|
||||
</video>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
showFunctions.addPlayPauseToVideo();
|
||||
</script>
|
Loading…
Reference in a new issue