Page 52 of 52

Re: [3.2][BETA] Custom Code

Posted: Thu Feb 14, 2019 10:55 pm
by martti
John connor wrote:
Thu Feb 14, 2019 10:35 pm
Question: I rely on this extension right now for a lot of things. When phpBB updates to version 4, do you think this extension will still work? I have added a lot of footer stuff and I'd like to keep it there. Then during Christmas I have code on the index that randomly plays a Christmas audio clip.
4? I'm unaware about that. Are they working on version 4 at the moment?

Re: [3.2][BETA] Custom Code

Posted: Thu Feb 14, 2019 11:18 pm
by david63
John connor wrote:
Thu Feb 14, 2019 10:35 pm
Question: I rely on this extension right now for a lot of things. When phpBB updates to version 4, do you think this extension will still work? I have added a lot of footer stuff and I'd like to keep it there. Then during Christmas I have code on the index that randomly plays a Christmas audio clip.
As we do not know what is in phpBB 4, or even when it may appear, I doubt that at this point anyone can answer that question. My personal view is that many, if not all, extensions will not work in phpBB 4

Re: [3.2][BETA] Custom Code

Posted: Mon Sep 02, 2019 12:31 pm
by John connor
What code would I use to play audio on login only? I have code that can play audio on the index which I use at Christmas, but how would I do it just on login? I don't know PHP.

Re: [3.2][BETA] Custom Code

Posted: Tue Sep 03, 2019 6:15 am
by martti
John connor wrote:
Mon Sep 02, 2019 12:31 pm
What code would I use to play audio on login only? I have code that can play audio on the index which I use at Christmas, but how would I do it just on login? I don't know PHP.
Maybe check on a template variable that comes with the login box:
(i.e in the overall_footer_page_body_after template event)

Code: Select all

{%- if S_LOGIN_ACTION -%}
Your code here
{%- endif -%}

Re: [3.2][BETA] Custom Code

Posted: Wed Sep 04, 2019 3:28 am
by John connor
I used the audio code I got from you a few years ago as a test, but this doesn't seem to work. This is what I added to overall_footer_page_body_after


Code: Select all

{%- if S_LOGIN_ACTION -%}
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/ogg" style="display: none;">   
</audio>
<div id="playing" style="display: none;">
</div>
<script>
var audio;
var playlist;
var tracks;
var current;
var musicarr = ["https://www.mywebsite.com/images/bells.ogg",
                "https://www.mywebsite.com/images/bells2.ogg",
                "https://www.mywebsite.com/images/bells3.ogg",
                "https://www.mywebsite.com/images/christmas.ogg",
                "https://www.mywebsite.com/images/santa.ogg",
                "https://www.mywebsite.com/images/noel.ogg",
                "https://www.mywebsite.com/images/hoho.ogg",];
shuffle(musicarr);

init();
function init(){
    current = 0;
    audio = $('audio');
    audio[0].volume = .20;
    len = musicarr.length;
   
    run(musicarr[current], audio[0]);
   
    
}

function run(link, player){
        player.src = link;
        audio[0].load();
        audio[0].play();
        $('#playing').html("<ul><li><a>" + link+ "</a></li></ul>");     
}

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex ;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}
</script>
{%- endif -%}

That code was added to your extension inserttemplatecode.

Re: [3.2][BETA] Custom Code

Posted: Wed Sep 04, 2019 1:38 pm
by </Solidjeuh>
martti wrote:
Tue Sep 03, 2019 6:15 am

Code: Select all

{%- if S_LOGIN_ACTION -%}
Your code here
{%- endif -%}
This is not working, it's playing the sound on every page you open