The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

We are looking for a code that plays music only on one topic

5 posters

Page 1 of 2 1, 2  Next

Go down

Solved We are looking for a code that plays music only on one topic

Post by Lusuce September 4th 2019, 7:13 pm

Hello everyone. before describing my problem and everything, I just want to make clear that english isn’t my native language, so, sometimes, it can be difficult to understand what I mean. So sorry in advance!

Now, back to the main issue: I’m one of two secondary GM’s (the creator of the forum being the main guy) in a RPG forum (forumactif, french version), and, we wanted to know if it is possible to play a certain music in a certain topic (all the pages of the topic, that’d be handy).

Right now, the best we came with (and it’s pretty bad lmao) is someting that just plays a youtube video. The video pops in the top left corner, and, you just click play, and music plays. But, there are issues with this, and that’s why we come here.

Firstly, we’d like not to have a big square hiding the background of the forum, just a little ”play/pause” button in a corner would do the trick.
Secondly, if the code that plays the music included a fixture that made it able to play the music in all the pages, not just one.

If I was unclear, or you need more info, please ask, I’ll respond when I have time. Thanks in advance, and, I hope someone can find a solution for us.

Thx for reading, and have good day! Smile


Last edited by Lusuce on September 9th 2019, 8:49 pm; edited 1 time in total
Lusuce
Lusuce
New Member

Posts : 4
Reputation : 1
Language : French/English

http://jean-charles.1fr1.net

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 4th 2019, 7:51 pm

Hello,

It is very possible and quite easy to do. This code should do the trick:
Code:
var tid=100;
var file="http://soundbible.com/grab.php?id=2079&type=mp3";
if(location.pathname.indexOf("t"+tid)===-1) return;
document.addEventListener("DOMContentLoaded", function(){
var body=document.querySelector("body");
var audio=document.createElement("audio");
audio.setAttribute("src", file);
audio.setAttribute("controls", "");
body.appendChild(audio);
})

Also add this CSS to make the element stay at the top of the page:
Code:
audio{
position:fixed !important;
top:0 !important;
right:0 !important;
}

The number on the first line of the first code(100) is the id of the topic and you can find it in the topic's url. For example, this topic's url is https://help.forumotion.com/t157903-we-are-looking-for-a-code-that-plays-music-only-on-one-topic#1095887, where the bold part is the id.
The second line is the url to the sound file. If the code doesn't work, please leave it enabled so I can see what went wrong.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 4th 2019, 10:41 pm

Hi Occultist, thank you again for your help !

So we tried, and it doesn't seem to work ! The code was put as a new java script : http://prntscr.com/p1wbqj

What do you think is the problem ? Here is the topic we wanted the music on : http://continentem.forumactif.com/t563-la-forge

(For now we used your music link, believing the problem was our youtube link, so is it possible with a youtube link anyway ?)

And last add : our forum is on ModernBB, Lusuce didn't know about the different forum logos !
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 4th 2019, 10:46 pm

Try all pages, not just in topics.


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 4th 2019, 10:47 pm

SLGray wrote:Try all pages, not just in topics.

Just tried it, still not working hmm
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 4th 2019, 10:49 pm

Do you have JavaScript Management activated?  I asked because I do not see the script in the page source.


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 4th 2019, 10:50 pm

Strange... Because we do : http://prntscr.com/p1wg4h
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 4th 2019, 11:00 pm

Did you add the CSS to your CSS stylesheet?  Also did you add your own music to the JavaScript?


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 4th 2019, 11:10 pm

Here for the CSS : http://prntscr.com/p1wnxc

And we tried with a youtube link, then with the link Occultist provided. In both cases : it doesn't work Sad
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 6th 2019, 5:19 pm

I made a slight error. See if this works:
Code:

;(function(){
var tid=563;
var file="http://soundbible.com/grab.php?id=2079&type=mp3";
if(location.pathname.indexOf("t"+tid)===-1) return;
document.addEventListener("DOMContentLoaded", function(){
var body=document.querySelector("body");
var audio=document.createElement("audio");
audio.setAttribute("src", file);
audio.setAttribute("controls", "");
body.appendChild(audio);
})
})();

As about youtube videos, you will need to download the audio file. You can find a lot of services that do this online. For example, this one:https://ytmp3.cc/

After downloading it you need to upload it somewhere. Again, you can find online services for this too or I can do it for you if you post the link to the youtube video here.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 6th 2019, 5:22 pm

Not working yet, hmm am I doing it right : http://prntscr.com/p2q8zl ?

Ok for youtube videos, I will do it this way then, had done something similar in the past, so I know how to, but thank you for the proposal I love you
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 6th 2019, 5:50 pm

Try adding a
Code:
;
exactly at the end of the code(no spaces). Forumotion compresses the javascript code, which is a good thing but can lead to some issues.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 6th 2019, 6:21 pm

http://prntscr.com/p2r0eo

Like that ? Not working Confused
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 6th 2019, 6:56 pm

You have this code in one of your javascript files:
Code:
< img src = "https://image.noelshack.com/fichiers/2018/36/2/1536091220-barre-aard.png"
width = "40"
height = "12"
alt = "1/5"
style = "object-fit:cover;" >
That is html code and it needs to be removed for other javascript codes to work.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 6th 2019, 6:58 pm

Done, but no changes seen hmm

Edit : + other scripts were working anyway with the html code Confused ; like the script you made for the changing backgrounds
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 6th 2019, 7:07 pm

You can see the audio player at the bottom of the page. Adding the CSS code from my first post should move it to the top of the page.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 6th 2019, 7:09 pm

Oh... Yes, it's actually there !! But hum, the script is already in the CSS : http://prntscr.com/p2rl4a ; so maybe there is something wrong ?

And by the way, is it possible to personalise the look of the player ?
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 6th 2019, 7:23 pm

The css code doesn't appear in the css file(http://continentem.forumactif.com/32-ltr.css). Are you sure you added it?

The player can be stylised, but different browsers have different default styles for it. Some may even not allow modification of that element. A workaround to this would be making a custom player. Let me know if that's what you want.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 6th 2019, 7:33 pm

I added it in the CSS sheet, I don't know if it's correct hmm ?

And yes, that's what I'd like to have, a player in the theme of the forum, maybe I should make a request in the graphic section ? Or just find an appropriate image in the web haha
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Guest September 6th 2019, 7:54 pm

I'll work on making a custom player and we'll see about the design after I finish that part. Do you need to be able to modify the volume for the player and to be able to skip to a certain part?

Also, the CSS code still doesn't appear, but we'll see about that after.
avatar
Guest
Guest


Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 6th 2019, 7:56 pm

Would be great to be able to modify the volume, while skipping isn't necessary !

Thank you very much, and I don't know why it doesn't go for the CSS code, because it's there in fact Confused
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 6th 2019, 7:59 pm

Did you click the submit or save button on the CSS stylesheet page?  You have to click the submit button when adding CSS to the stylesheet.  If you are changing the option below it, you click the save button.


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Lusuce September 6th 2019, 8:39 pm

We never forgot to save or validate any modifications. It must be something else that’s causing us problems.
Lusuce
Lusuce
New Member

Posts : 4
Reputation : 1
Language : French/English

http://jean-charles.1fr1.net

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 6th 2019, 8:52 pm

Please post a screenshot of your CSS stylesheet.  Also upload it with editor (host an image button).


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Lusuce September 6th 2019, 9:33 pm

https://2img.net/image.noelshack.com/fichiers/2019/36/5/1567797088-9e2bf0e0-3be2-4242-9b6e-da01f0327f48.jpeg

Is that what you asked for? Sorry if it’s not! Could you detail your needs if so? As I said, none of us are native speakers so sometimes there can be misinterpreations.
Lusuce
Lusuce
New Member

Posts : 4
Reputation : 1
Language : French/English

http://jean-charles.1fr1.net

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 7th 2019, 12:36 am

Add the CSS code to the top of the styelsheet,


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 7th 2019, 12:39 am

That works, but the player is there : http://prntscr.com/p2vcxc

Not usable aha
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SLGray September 7th 2019, 12:45 am

In the CSS code, change the zero in the top line until you get what you want.

I mean this:
Code:
top: 0 !important;


music - We are looking for a code that plays music only on one topic Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by Gurufissu September 7th 2019, 1:02 am

That does work ! Thank you !

I'll wait for Occultist code, before putting the topic as solved, thank you guys !
Gurufissu
Gurufissu
Forumember

Posts : 142
Reputation : 2
Language : French

http://continentem.forumactif.com/

Back to top Go down

Solved Re: We are looking for a code that plays music only on one topic

Post by SarkZKalie September 7th 2019, 12:23 pm

You can try this SCM Music Player


music - We are looking for a code that plays music only on one topic Sarkzk10
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1418
Reputation : 220
Language : English

https://rotavn.forumotion.com/

Back to top Go down

Page 1 of 2 1, 2  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum