Question

I noticed that if you're playing a song at http://listen.grooveshark.com/ and you hit the back button Flash is smart enough to keep on playing the music while navigating "back" inside the Flash application.

Is it possible to implement this sort of thing using Java Applets, or do Applets alway shut down when you navigate away from the page (even though the resulting page contains the same applet)?

Was it helpful?

Solution

Looks like grooveshark is being tricky with the URL fragment. They store the search after the # fragment delimiter in the URL, e.g. do a search for ween, and you get this URL

http://listen.grooveshark.com/#/search/songs/?query=ween

Then do a search for bungle and the URL changes to

http://listen.grooveshark.com/#/search/songs/?query=bungle

If you click the back button in your browser, the URL changes to the previous "ween" one, but the browser remains on the same page, because everything before the fragment identifier is the same. There's some javascript that's detecting the changed fragment and updating the UI accordingly.

You could probably do something like this with an applet, but it seems better suited to javascript. The good news is, your applet is going to be cached by the browser, so if you do switch to a different page the applet loading will happen quickly.

OTHER TIPS

http://java.sun.com/docs/books/tutorial/deployment/applet/lifeCycle.html

When the user leaves the page, for example, to go to another page, the browser stops and destroys the applet. The state of the applet is not preserved. When the user returns to the page, the browser intializes and starts a new instance of the applet.

That being said, what you could do is save the state to the server when the applet is stopped and then restore the state from the server when it starts again. If you make it a signed applet it should be able to save the state locally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top