Skip to main content
Topic: Play Music Once - JavaScript (Read 2217 times) previous topic - next topic

Play Music Once - JavaScript

If anyone has ever wanted to code a web page so that a music file (such as MIDI) is played exactly once when a visitor first arrives, but is not replayed even if the page is refreshed or left and revisited in the same session, try this:

http://www.icogitate.com/~ergosum/misc/playonce.zip

The only way for the visitor to replay your music would be to close the browser, then re-open to your page.

Re: Play Music Once - JavaScript

Reply #1
hello

 

Re: Play Music Once - JavaScript

Reply #2
oops ... my above link is obsolete. But if anyone really wants to know how it is done: Have the web page attempt to read a cookie (set previously by the same web page) as it loads. If the cookie is there, the media file is not played, and the cookie is set for the next time. Make it a temporary cookie, so that the media file will play in a future browser session.

NWC: If you wish, you can remove this thread.