Welcome Messages - Tips & Tricks

html

#21

@Bibliophile I tried this code, didn’t work. Any advice?
See below. I am trying to play an MP3 file from a website which hosts it.
Maybe I can’t do that?

< script >
Var playing = false;
Window.addEventListener(‘touchstart’, function(){
If(!playing) {
Var mya = new audio(‘https://downloads.khinsider.com/game-soundtracks/album/heroes-of-might-magic-2/04-city-of-the-sorceress.mp3’);
Mya.play();
Playing = true;
}
});
< /script >

(Without the spaces before and after script and /script)


#22

Few issues:

  1. Javascript is case sensitive.
  2. Your audio link doesn’t go to the actual mp3 file.

Give this a shot:

<script>
var playing = false;
window.addEventListener('touchstart', function(){
    if (!playing) {
        var mya = new Audio('http://66.90.93.122/ost/heroes-of-might-magic-2/nvncrnxwtj/04-city-of-the-sorceress.mp3');
        mya.play();
        playing = true;
    }
});
</script>

#23

Hey @Bibliophile , thanks for this. In theory, this should work fine but I can’t seem to get it to work on the Welcome page.

I even deleted all code and then copied and pasted this by itself, but it doesn’t play the music.
However, directly pasting the URL into my browser works. :thinking: I wonder how to make this work…


#24

I failed, sorry, audio should have been Audio, also I missed fixing the “fancy” quotes around touchstart.


#25

Outstanding! It actually works! :sunglasses::smiley:

There’s a small delay before the music plays but otherwise works like a charm!
Thank you sir, the Empire is in your debt.


#26

Try this:

<audio autoplay>
  <source src="http://66.90.93.122/ost/heroes-of-might-magic-2/nvncrnxwtj/04-city-of-the-sorceress.mp3" type="audio/mpeg">
</audio>

I got the URL from @Bibliophile’s post.


#27

Thanks, it’s working now, although most people skip the welcome page, but it’s good to have music while reading the rules.


#28

This instantly plays. :slight_smile:


#29

Ah, that’s a good idea Wingy. I’ll update the OP to recommend that method, much simpler.


#30

One thing that I’d like to see is replacing the background image, not only where the welcome message content itself is but also along the top and bottom, because it always annoys me that there’s a break in the time-crystally background that is filled with a white box with all the content. :slight_smile:


#31

So something like this?

<style>
#messageContent {
    background: transparent;
}
</style>

#32

Disclamer: I don’t have a server this is my hosted single player wolrd!

@Bibliophile How do i remove this?

IF YOU ARE IN A MULTIPLAYER WORLD MAKE SURE YOU LISTEN TO MODS AND ADMINS AND DONT BE RUDE OR YOU MIGHT GET BANNED FOR NO REASON

#33

Please don’t SHOUT!

<script>
    addEventListener('load', function() {
        document.querySelector('center[style="font-size:80%"]').remove();
    });
</script>

#35

@bibliophile this dosent work

I never shouted?


#36

What are you trying to remove exactly?


#38

I think he meant the fact that you used bold and large words.


#39

The random text under the welcome message


#40

Oh, all I do is:
<style

At the end of all the code.
It works.


#41

Fixed the code above, I’m so used to loading scripts after the page is completely loaded I forgot that element didn’t exist yet.

<script>
    addEventListener('load', function() {
        document.querySelector('center[style="font-size:80%"]').remove();
    });
</script>

#42

Or a more easy, but completely incorrect and will break your welcome message if it isn’t viewed in a good browser (the blockheads welcome message viewer is good):

<!--