Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
September 09, 2026 - @833.59
Activity rating: Four Stars Posts & Arts: 73/1k.beats Random | Recent Posts | Guild Recents
News: inconvenience is counterculture :eyes: Guild Events: weekly zine theme 11: tools

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  Playable Music Button


« previous next »
Pages: [1] Print Embed
Author Topic: Playable Music Button  (Read 518 times)
willyonilly
Newbie ⚓︎
*
View Profile WWW


BILLYBILLY
⛺︎ My Room

Artifacts:
Joined 2026!
« on: August 08, 2026 @723.65 » Embed

Hello! I finally got a music button working and wanted to share the code!!! I have this in a container on top of an image, so if you want it separate, you might have to tinker with it some.
 
You'll add this inside your STYLE tag:

        .music-button {
            position: absolute;
            top: 50px;       /* Adjust this number to move the button up or down! */
            left: 50px;      /* Adjust this number to move the button left or right! */
            background: none;
            border: none;
            cursor: pointer;
            z-index: 10;     /* Ensures the button stays on top of the image! */

In your BODY tag above the container, you'll add this. It's your script to make the music play:
 
    <audio id="myMusic" src="MUSIC.MP3"></audio>

    <script>
        function toggleMusic() {
            var audio = document.getElementById("myMusic");
            var img = document.getElementById("buttonImage");
            if (audio.paused) {
                audio.play();
                img.src = "YOUR_PAUSE_BUTTON.PNG";
            } else {
                audio.pause();
                img.src = "YOUR_PLAY_BUTTON.PNG";
            }
        }
    </script>

Beneath this, add your container! Beneath the container code, you'll add this:

            <button onclick="toggleMusic()" class="music-button">
                <img id="buttonImage" src="YOUR_MUSIC_BUTTON.PNG" alt="Play Music" width="100">
            </button>

All in all, it should look like this! This image, of course, contains my own chosen song + the assets I created!
https://file.garden/anYfh4-1EEBDJOQ2/Screenshot%202026-08-08%20111951.png

Logged

Glory to you and your House!
MrsMoe
Hero Member ⚓︎
*****
View Profile WWWArt


Your friendly neighborhood living dead girl
⛺︎ My Room

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!Deviantart Llama!Great Posts PacmanFirst 1000 Members!Joined 2022!
« Reply #1 on: August 08, 2026 @796.13 » Embed

What exactly should it look like on your webpage once it's implemented?

Logged

https://blinkies.cafe/b/display/0113-autism.gifhttps://blinkies.cafe/b/display/0021-vampirefangs.gifhttps://blinkies.cafe/b/display/0182-halloweencathouse.gifhttps://i.postimg.cc/02L6smjc/ezgif-7-ebef155de1.gifhttps://64.media.tumblr.com/e53076104c8d22ed3d272d62cc8fccfa/88280e3f54890c11-c1/s250x400/aa5c1239ea59888acaa71ad26271790a794ccc5d.gifvhttps://blinkies.cafe/b/display/0138-greenglow.gif
https://i.ibb.co/Lzg2SZj/tumblr-5afbadec7c65089061ba8cfa48b57bc8-469c61aa-100.webphttps://tinyurl.com/yn2v726zhttps://tinyurl.com/39tjbzfmhttps://tinyurl.com/32x3t38jhttps://tinyurl.com/2ybkhmh5https://tinyurl.com/2ue7d945https://tinyurl.com/493hsx5phttps://tinyurl.com/ye28hzrphttps://64.media.tumblr.com/92ec86321325be8fac199fecef8fd7b0/tumblr_ptpl0x7U4o1y8ua8do1_100.gifv
Rubbereon
Sr. Member ⚓︎
****
View Profile WWWArt


⛺︎ My Room
SpaceHey: Friend Me!
Matrix: Chat!
XMPP: Chat!

Guild Memberships:
Artifacts:
NoSmoking!Hope, the silliest ink kittayyVisited on Melon's 10th Anniversary!Joined 2025!
« Reply #2 on: August 08, 2026 @808.40 » Embed

Nice, but have you tried scmplayer or wikplayer before before making a custom widget?  :eyes:

Also bear in mind that music just cannot play automatically, you could maybe before 2020, but now it's required for the user to click on the webpage first before the music would play.

Logged

https://bettysgraphics.neocities.org/images/animals/cat%20695.gifFuzzy fwiendhttps://bettysgraphics.neocities.org/images/animals/cat%20696.gifhttps://bettysgraphics.neocities.org/images/animals/cat%20697.gif
https://rubbereon.nekoweb.org/img/penguin.gifLinux userhttps://rubbereon.nekoweb.org/img/penguin.gif
↓ All my web profiles are available on this website ↓
https://fursona.directory/@rubbereon :eyes:

Artifact Swap: pearl yappin kittaydiamond yappin kittayGreen Spiffo
willyonilly
Newbie ⚓︎
*
View Profile WWW


BILLYBILLY
⛺︎ My Room

Artifacts:
Joined 2026!
« Reply #3 on: August 08, 2026 @829.83 » Embed

What exactly should it look like on your webpage once it's implemented?

Mine looks like this: https://file.garden/anYfh4-1EEBDJOQ2/Screenshot%202026-08-08%20135259.png
The big red button is the music player. If tinkered around with, you could probably get it to sit somewhere else - the code I shared is to specifically get it to sit atop another image, but I could try to conjure up some code to have it separate!!!

Logged

Glory to you and your House!
willyonilly
Newbie ⚓︎
*
View Profile WWW


BILLYBILLY
⛺︎ My Room

Artifacts:
Joined 2026!
« Reply #4 on: August 08, 2026 @831.16 » Embed

Nice, but have you tried scmplayer or wikplayer before before making a custom widget?  :eyes:

Also bear in mind that music just cannot play automatically, you could maybe before 2020, but now it's required for the user to click on the webpage first before the music would play.

I haven't! I usually end up doing things the hard way, LOL. I like to make things difficult for myself. I also am slightly obsessed with everything on my site being Klingon-themed. If I can't customize it to the utmost degree, I just make my own!
Don't worry - I made it that way on purpose! I, myself, always get a little irritated when I have to manually mute an entire site because I don't want to listen to the music that's playing. I prefer to have it be manual to play it!

« Last Edit: August 08, 2026 @843.66 by willyonilly » Logged

Glory to you and your House!
MrsMoe
Hero Member ⚓︎
*****
View Profile WWWArt


Your friendly neighborhood living dead girl
⛺︎ My Room

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!Deviantart Llama!Great Posts PacmanFirst 1000 Members!Joined 2022!
« Reply #5 on: August 09, 2026 @854.65 » Embed

Mine looks like this: https://file.garden/anYfh4-1EEBDJOQ2/Screenshot%202026-08-08%20135259.png
The big red button is the music player. If tinkered around with, you could probably get it to sit somewhere else - the code I shared is to specifically get it to sit atop another image, but I could try to conjure up some code to have it separate!!!

Cool! I technically already have a music player on my site, but it's regulate to a single page. It'll be cool to have one that follows the user around the site.

Logged

https://blinkies.cafe/b/display/0113-autism.gifhttps://blinkies.cafe/b/display/0021-vampirefangs.gifhttps://blinkies.cafe/b/display/0182-halloweencathouse.gifhttps://i.postimg.cc/02L6smjc/ezgif-7-ebef155de1.gifhttps://64.media.tumblr.com/e53076104c8d22ed3d272d62cc8fccfa/88280e3f54890c11-c1/s250x400/aa5c1239ea59888acaa71ad26271790a794ccc5d.gifvhttps://blinkies.cafe/b/display/0138-greenglow.gif
https://i.ibb.co/Lzg2SZj/tumblr-5afbadec7c65089061ba8cfa48b57bc8-469c61aa-100.webphttps://tinyurl.com/yn2v726zhttps://tinyurl.com/39tjbzfmhttps://tinyurl.com/32x3t38jhttps://tinyurl.com/2ybkhmh5https://tinyurl.com/2ue7d945https://tinyurl.com/493hsx5phttps://tinyurl.com/ye28hzrphttps://64.media.tumblr.com/92ec86321325be8fac199fecef8fd7b0/tumblr_ptpl0x7U4o1y8ua8do1_100.gifv
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 Melon
Land
Editor Recent Edits Tenement Arcade Random Link Land → Forum Art Hub Chat Webring Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Newsletters Image Stream Zap!
Minecraft: Online
Join: craft.melonking.net