Search…

X3 Photo Gallery Support Forums

Search…
 
pinkrabbit1357
Topic Author
Posts: 19
Joined: 28 Aug 2022, 18:02

disable audio player in a single page

03 Sep 2022, 11:15

I have enabled the audio player in the settings. Is it possible to disable it in a single page only via js or other custom code? thanks
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: disable audio player in a single page

04 Sep 2022, 00:23

When you say "disable it", what exactly do you mean? If the audio player already exists, it might be playing or not. You could perhaps stop it via Javascript (if it's playing), but what will you do when visitors navigates away from the page? Try to restart the audio? Then you will need to track and store the play status of the audio player.

You could STOP it via Javascript, but you probably don't want to make it complicated be automatically restarting again after user navigates away from the page.
 
pinkrabbit1357
Topic Author
Posts: 19
Joined: 28 Aug 2022, 18:02

Re: disable audio player in a single page

04 Sep 2022, 10:24

I do not want audio player in some pages at all e.g. video page because my videos have music embedded in them already. I guess I could remove either the "x3_plugin_buttons" or "button_audioplayer" in Page Javascript? 
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: disable audio player in a single page

04 Sep 2022, 11:16

You did not really answer my question though. If you remove the element with Javascript, how do you expect it to come back when you navigate back to a page where the audio player should exist? X3 does not reload the entire document and restart audio when you navigate.

Unlike any other visual element on page, which can be hidden on a per-page basis, "audio" will not stop playing by simply "removing" the button. You would have to stop the audio, but then you can't expect it to automatically restart again when user navigates back to a page where the audio player should exist.
 
pinkrabbit1357
Topic Author
Posts: 19
Joined: 28 Aug 2022, 18:02

Re: disable audio player in a single page

04 Sep 2022, 19:03

I do not want audio to load in this page ever. Right now the default audio is in the page because audio has set globally. 
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: disable audio player in a single page

04 Sep 2022, 23:43

pinkrabbit1357 wrote: I do not want audio to load in this page ever. Right now the default audio is in the page because audio has set globally. 
You are not reading my post properly. I am not talking about the page where you want to disable it. I am talking about pages that the visitor navigates to AFTER the page where you want it disabled. If you remove the audio element and/or stop the audio on the page where you want it disabled, then it will be gone also for the following pages that the visitor navigates to.
 
pinkrabbit1357
Topic Author
Posts: 19
Joined: 28 Aug 2022, 18:02

Re: disable audio player in a single page

05 Sep 2022, 10:13

Doesnt page javascript apply the logic to that page only? I didnt know that the logic gets carried over to the subsequent pages. 
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: disable audio player in a single page

05 Sep 2022, 12:02

X3 is a SPA (single-page application). How do you think the audio player continues to play uninterrupted when you navigate between pages? Audio player is a global element, and it does not RELOAD or RESTART on a per-page basis ... That would be clumsy, and of course a useless feature, because the audio would not be seamless.

Of course javascript on that page would apply for that page, but how would you expect the audio player to magically restart and re-appear when you navigate away to another page again if you have STOPPED and/or REMOVED it via Javascript. I'm struggling to see how this is so difficult to understand. Surely you can see that the audio player does not get removed and restarted on each page? ... And that if you remove it, how/why would X3 automatically think "hey, someone removed and stopped the audio player via custom javascript ... hold on, let me create it again, and restart the audio ..."

As mentioned, you can possibly STOP the audio and perhaps HIDE the audio player on that page. The audio player will re-appear when you navigate to other pages, but it won't automatically start playing again.