I have the following blocks implemented. Can not get it to work as planned.
Each section called on the same page by the viewer is an audio file. The button clicks to randomly select a different section. It is all fine, if the audio play is stopped before the button clicks.
While the audio is being played, and the user click the button, the webviewer switches to another section, the visual changes, but the audio from previous section still plays in the background. What can you advise. Thank you.
Add this line off code in website. This event is called whenever tab is unfocussed if you change page then i think this works window.onblur = function (){ const audio = document.getElementById('audio'); audio.stop() }
Where audio is id of element you may have different
ShaikhSajidAli, Thank you for your support. I see that you were trying to use some audio tag to stop it. I don’t know about audio tag. I was using hastag in the Url to identify each audio section as follows:
jQuery( document ).ready( function () {
if(window.location.hash) {
var hashtag = location.href.substring(location.href.indexOf("#")+1);
var divtoShow = jQuery("#" + hashtag);
var hashtagstring= hashtag.substr(0, hashtag.indexOf('-'));
if ( divtoShow.length > 0 ) {
for (i = 1; i < 500; i++) {
if ( hashtag == hashtagstring + "-" + i ) {
divtoShow.show();
} else {
jQuery("#" + hashtagstring + "-" + i).hide();
}
}
}
}
function hashHandler() {
if(window.location.hash) {
var hashtag = location.href.substring(location.href.indexOf("#")+1);
var divtoShow = jQuery("#" + hashtag);
var hashtagstring= hashtag.substr(0, hashtag.indexOf('-'));
if ( divtoShow.length > 0 ) {
for (i = 1; i < 500; i++) {
if ( hashtag == hashtagstring + "-" + i ) {
divtoShow.show();
} else {
jQuery("#" + hashtagstring + "-" + i).hide();
}
}
}
}
}
window.addEventListener('hashchange', hashHandler, false);
window.addEventListener('locationchange', function(){
hashHandler();
});
});
I entered
jQuery("#" + hashtagstring + “-” + i).stop(true);
under the
jQuery("#" + hashtagstring + “-” + i).hide();
But it does not work.