Log in

View Full Version : How to link music from page to page



DragginGlass
07-16-2007, 03:34 PM
Aight I don't know if this is the right place for this question but I need to find out how to link a song from one page on my site to another without it starting over. I can put the same song on both pages but when you leave one page and go to the other it starts over.

Now from past forum experience I have found that this question tends to get alot of opinions about putting music on a website, some like it, some hate it, some don't care. I don't mean to sound like a prick or anything but I built my website specifically for my car club and my car club only and we all like the idea of having music on it so if you can help me with my question then I thank you in advance, if you can't then please don't leave your opinions as they are not helpful. Thanks

djr33
07-16-2007, 03:45 PM
Having any media on a webpage presents trouble as it isn't just html, or even javascript, something that you can easily control.

Basically, I can't think of a way to do this, not at least without using a couple tricks that have some downsides.

With embedded elements, you can have some very limited control through javascript, depending on which plugin is used (and this depends on the user's configuration), but I'm not aware of any that allow for setting it to a specific time.

One option would be to use flash, store a cookie to keep track of the song and then play it on the next page, but flash is a pain to use (proprietary, users must have it installed, and its interaction with other elements on the page can get complex) and you might not have it anyway. This probably the most reliable cross-page option, if not the only one (with the possible exception of Java applets). However, even this would be somewhat difficult. You'd have to look into ActionScript accessing the timecode of a sound file. I'd assume it's possible though.

Another option, far simpler, though bad in terms of overall design would be to use a frame based layout and not reload the music player frame. It's fairly simple, would allow for the music to continue even while other pages load, and it wouldn't be hard to make. However, it's a bad idea to use frames if you can avoid it, generally.

Along those same lines, perhaps the best idea is to simply have a pop up window, play the media in that, do whatever you want (minimize, resize, put behind the main window, leave in the center of the screen, etc.) and continue on the main site, reloading all you want, without affecting the pop up.
The downside to pop ups is that they tend to really annoy visitors and just get in the way. But if you and your visitors all want this media player (as it sounds like you do), that shouldn't be much of a problem.

DragginGlass
07-16-2007, 03:49 PM
Dude, that is exactly what I am looking for, the pop up thing you talked about. Do you have any knowledge of how to do this?

jscheuer1
07-16-2007, 03:52 PM
The two easiest ways I can think of are iframe or frameset.

With a frameset, you have one page in a very small frame in the frameset. This page has the noise on it. You then have one other large frame that takes up the whole page that is the navigation frame, all pages on the site show through it.

With an iframe, you have a page with the code for the noise on it that also has an iframe that takes up the whole visible page, this iframe is where navigation around the site takes place, showing through the iframe.

I think the frameset idea is more manageable, as it is easier to arrange it to look like it's just one page (framesets can more easily use percentage values for size in both the horizontal, and (more importantly) vertical dimensions of a page/window.

DragginGlass
07-16-2007, 03:57 PM
Ok you guys certainly know way more than I do, is there some place I can get a tutorial on how to do a frameset or iframe? Or possibly be kind enough to explain it to me. Thank you

djr33
07-16-2007, 04:06 PM
A popup window is very easy.

<a href="mypopup.htm" target="_blank" onClick="window.open(this.href); return false;">

That will set the page with href, set it to open in a new window with target=blank, and override this with javascript (IF javascript is enabled, so you still have the fallback if not) to allow for more parameters.

I'd normally hesitate to link to something from microsoft, but this seems to give enough info--
http://msdn2.microsoft.com/en-us/library/ms536651.aspx
It was just the first google result of "window.open" anyway, so search for that if you need more info.
Basically, window.open(href,target,paremters,etc), and you can set stuff like size of the window, etc.


Frames are fairly easy. Google frameset, and find an example or tutorial.
Basically, a frameset is like a bookcase, but instead of rows of books, it holds webpages. It, well, frames them. You can have two frames in a single page, and then have two webpages in one window. With this, you can leave the media player open in one part of the window and have the other able to navigate pages, etc.

iframes could work too, but as John said, probably better to use frames here. iframes are better if THEY are changing, and are the smaller/embedded content, not the main page changing and the iframe staying as is, since the page changing around the iframe would lose the iframe as well. So, you would have to switch them and have the iframe be the main page within the media player.
...anyway, probably not a good idea.

One downside to using frames (or iframes) is that the URL won't change in the address bar, and you can't bookmark specific pages.

DragginGlass
07-16-2007, 04:31 PM
Ok, man, I am sorry but I guess the way you describe this is like japanese to me..lol. Do I paste

<a href="mypopup.htm" target="_blank" onClick="window.open(this.href); return false;">

that into my html or what? If so then is there a certain place I need to paste it? Also how do I get my music in the pop up? Sorry to be such a bother but I have never done this and it's way confusing, but I really need to learn if you can bare with me.

alexjewell
07-16-2007, 04:56 PM
You wrap that around the link the user will click on to see the popup, as so:



<a href="mypopup.htm" target="_blank" onClick="window.open(this.href); return false;">Click here to listen to the song!</a>


And of course, mypopup.htm would be replaced by the specific name of the page with your music on it.

DragginGlass
07-16-2007, 05:07 PM
so do I put this on every page or just the first one?

alexjewell
07-16-2007, 05:13 PM
You put that on every page you want a link to show up.

DragginGlass
07-16-2007, 05:34 PM
is there any way to hide that window?

djr33
07-16-2007, 05:34 PM
The link just opens a popup window. Then that window is separate from your site. It can play the file, or even navigate to another page... whatever, completely unrelated to your main window for the site.

DragginGlass
07-16-2007, 05:35 PM
Also is there any way to make it auto start instead of having to click something

alexjewell
07-16-2007, 05:40 PM
That depends on medium in which you're playing the music. You can do this with flash pretty easily, which I recommend anyway.

djr33
07-16-2007, 05:41 PM
That is completely unrelated to the method for opening the window, etc.

And yes, it is possible, but the method for doing so is related to how you are playing the audio. There are many ways, and you just need to pick your favorite. With flash, it would be an ActionScript command. With quicktime, there's a value you can add to the embed tag. Etc.

jscheuer1
07-16-2007, 06:34 PM
I think the question is whether the pop up can happen automatically. No, it can't. Generally you want the user to begin the music anyway. You could set your player to start automatically so that all the user would have to do is to click on the link. Also, you could have a splash page for the site. Something that says what the site is and has a link 'CLICK To ENTER' to click. That link could both launch the pop up and take the user to the real first page.

DragginGlass
07-16-2007, 06:43 PM
Yeah yeah, John I think your on the right path with that idea. What exactly is a splash page and how does it work. See what I have right now is when you type in my domain name it comes up to our main page and it has a video with music playing right there and you click enter to actually go to our site and begin your fun. From that page on there is no music. I wanted the music from that opening page to continue throughout your experience at my site. Maybe this will better help you help me:)

jscheuer1
07-17-2007, 02:49 AM
Well, it sounds as though you already have a splash page of sorts. A splash page is a sort of gateway to a site. It has limited information usually. Just an image or two, the name and a short description of the site and (usually) just a link to the main page of the site. It can have links to a few main sections though.

Once you have this sort of page (it would generally now be your index page), folks navigating to the site will usually start with it. Once they click on a link, for example:


<a href="main.htm" onlick="mwin=window.open('music.htm','mwin','width=200,height=150,top=0,left=0');mwin.blur();return true;">ENTER</a>

As long as their browser allows it (most do), it will open a small music window in the background that could be set to auto play, while at the same time opening main.htm in the current window. A s they continue to navigate the site, the music will continue to play. The drawback is that there really is no reliable way of ending the music unless they find and close this small window, or unless the music stops by itself after a time.

You can try this out, but I think the frameset approach is more applicable, even with its drawbacks mentioned earlier.

DragginGlass
07-17-2007, 08:01 PM
ok, here is the music code that I want to put on my site and have it play on every page,.......

<div align=center><table cellpadding=0 cellspacing=0><tr valign=top><td><embed type='application/x-mplayer2' autosize='true' autostart='true' src='http://bestaudiocodes.net/videos/bacvid1.wmv' width='300' height='220' ShowControls='0' ShowStatusBar='0' loop='true' EnableContextMenu='0' DisplaySize='1' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/'></embed><br><embed type='application/x-mplayer2' autosize='true' autostart='true' src='http://www.BestAudioCodes.net/bacasx/d/djkhaled-wetakingoverfeatakonti.asx' width='300' height='44' ShowControls='1' ShowStatusBar='0' loop='true' EnableContextMenu='0' DisplaySize='1' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/'></embed></td></tr></table><br><b><font size=+1>We Taking Over feat. Akon, T.I.</font></b><br>By DJ Khaled<br><a href='http://www.BestAudioCodes.com' target=_blank>BestAudioCodes.com</a></div>


Do I need to use that code you posted above or what? Plus do I need to have that code on every page? And if I have to put that on everypage that I want music on do I have to have somewhere for them to click so the music starts or will it just start when the page opens? Thanks

jscheuer1
07-17-2007, 08:29 PM
Assuming that works on a page by itself, that is what would go on music.htm from my previous example.

Ryan Fitton
07-18-2007, 12:38 PM
Using a pop up box would be the most easiest option. For example, on my website I have used a pop up box for a music player, click here (http://h1.ripway.com/ryanfitton) for an example, go on the other stuff menu and scroll down to 'Music Player'. By using a pop up box it lets the music play even when the user is on a different page or website. On DD there is an excellent pop up greator, click here (http://dynamicdrive.com/dynamicindex8/popwin.htm) for the generator. :)