Hello, I'm making a HTML webpage for when people join my server on Garry's mod.
I've completed making the page, I just need to add music but I'm unsure on how.
I've tried using the following:
[HTML]<object style="height: 1; width: 1"><param name="movie" value="http://www.youtube.com/watch?v=fwS7VltJGGk?version=3&autoplay=1&loop=1"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="http://www.youtube.com/watch?v=fwS7VltJGGk?version=3&autoplay=1&loop=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="1" height="1"></object>[/HTML]
But it didn't work.
If I remember correctly there's a minimum size for YouTube videos when they're embedded. Just set the video size higher and use CSS to position it offscreen.
If you only want music, this code works:
[html]
<audio controls height="100" width="100" autoplay="true" hidden="true" loop="true">
<source src="./{name}.mp3" type="audio/mpeg" autoplay="true" hidden="true" loop="true">
<source src="./{name}.ogg" type="audio/ogg" autoplay="true" hidden="true" loop="true">
<embed height="50" width="100" src="./{name}.mp3" autoplay="true" hidden="true" loop="true">
</audio>
[/html]
You need 2 files; .ogg and .mp3 version. (There are [url="http://audio.online-convert.com/convert-to-ogg"]online converters[/url] if you need them)
Edit Autoplay / Hidden / Loop as needed. (True or False)
Please don't use this on a normal webpage; auto-playing music is seriously annoying. For a server 'welcome' thing; it may be less annoying...
It's all good, thanks guys.
There are other methods which I'll post, they might be easier for other people.
By welcome page I assume you mean your sv_loadingurl?
Here is one method:
[code]<iframe title="YouTube video player" id="musicframe" class="youtube-player" type="text/html" style="position: absolute; opacity: 0;" width="0" height="0" src="http://www.youtuberepeater.com/watch?v=QH2-TGUlwu4"; frameborder="0" allowFullScreen="1" allowtransparency="1"></iframe>[/code]
To change the song, you change the src='', it's as simple as that.
If you want more than one song to be played (not at the same time, randomized everytime you view the page), you can use this javascript code.
[code]<script language="JavaScript1.2">
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
var iframeprops='type="text/html" style="position: absolute; opacity: 0;" width="0" height="0" allowFullScreen="1" allowtransparency="1"'
var randomcontent=new Array()
randomcontent[0]="http://www.youtuberepeater.com/watch?v=QH2-TGUlwu4";
randomcontent[1]="http://www.youtuberepeater.com/watch?v=zIh5AHxh-Ok";
randomcontent[2]="http://www.youtuberepeater.com/watch?v=vABC_DYnjAU";
randomcontent[3]="http://www.youtuberepeater.com/watch?v=O7uJjY62WLc";
if (ie||dom)
document.write('<iframe id="random" src="" '+iframeprops+'></iframe>')
function random_iframe(){
if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("random") : document.all.random
iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
}
}
window.onload=random_iframe
</script>[/code]
It works exactly the same in the sense that you just have to change randomcontent[]="" into the URL you want, whether it's youtube or a local music file.
Sorry for the bad music examples.
That's one way to annoy the fuck out everyone joining your server I guess.
[QUOTE=SteveUK;39609603]That's one way to annoy the fuck out everyone joining your server I guess.[/QUOTE]
True, but I was just helping him out :P
[QUOTE=BeatAlex;39609638]True, but I was just helping him out :P[/QUOTE]
Well, this is annoying in general. It's music that will play at full volume that you can't pause or mute unless you ALT+TAB and use the Windows volume control on AwesomiumProcess.
Your Javascript also looks like something I'd expect to see on JavascriptKit in the early 2000's. Language attribute in <script> is somewhat of a giveaway. I would've thought that Opera would have document.getElementById by now (even on Presto) - plus it's unnecessary to check the user agent as it'll always going to be Awesomium.
Depends, some elevator theme played at a 30% volume would definetely make me stay on the server.
[QUOTE=Torekk;39609792]Depends, some elevator theme played at a 30% volume would definetely make me stay on the server.[/QUOTE]
No, I usually listen to music or watch YouTube / TV Shows / Movies on my second screen, it would annoy me to death.
Sorry, you need to Log In to post a reply to this thread.