2

On some websites it is possible to start playing audio and move to the other links on this website without stopping the audio (it continues playing while you are navigating). But when you refresh the page or move to another website, it stops. How do they do that? Basically if you go to the other page on the website using the a href tag the music will stop.

If they are using Ajax, won't the ajax slow down the website in this case? And how do they make the URL change then? Is this technique referred to as a 'single page website'?

Christian
  • 3,917
  • 2
  • 23
  • 40
Johny
  • 39
  • 1
  • 5
  • Those websites are using AJAX in order to display different pages.. You cannot do anything as the audio playing will stop when refreshing/redirecting the page – Mihai Matei Aug 12 '15 at 06:16
  • Won't ajax slow down the website in this case? And how do they make the url change then? Is this technique referred to a single page website? – Johny Aug 12 '15 at 06:17
  • AJAX is not slowing down the page.. the request load time should be the same as a regular page load.. You can change the URL: http://stackoverflow.com/questions/3338642/updating-address-bar-with-new-url-without-hash-or-reloading-the-page – Mihai Matei Aug 12 '15 at 06:30
  • Thanks a lot, and isn't it referred to single page website? I have read that they are bad for SEO – Johny Aug 12 '15 at 06:32
  • There are techniques to show search engines that you have dynamic URLs. Usually you must have regular pages which will be pointed to the dynamic URLs. Here is the Google answer to your question: https://developers.google.com/webmasters/ajax-crawling/docs/learn-more – Mihai Matei Aug 12 '15 at 06:34
  • Thank you a lot. You could have posted all of this as an answer. – Johny Aug 12 '15 at 06:36
  • Did you read my answer, @Johny? – Christian Aug 13 '15 at 05:51

2 Answers2

5

I think you'll find that its not AJAX being used at all. If you're referring to sites like Soundcloud that opens a 'player' and allows you to move around the site while the player is still playing, then that is the HTML5 History API.

See a very basic demo of the History API here.

View more about it at Dive Into HTML5.

EDIT;

Click through to Demo on this page for a great audio player example.

EDIT #2;

See this related question on StackOverflow.

Community
  • 1
  • 1
Christian
  • 3,917
  • 2
  • 23
  • 40
0

Those websites are using AJAX in order to display different pages.. You cannot do anything as the audio playing will stop when refreshing/redirecting the page.

AJAX is not slowing down the page.. the request load time should be the same as a regular page load.. You can find more details about changing the URL dynamically here: Updating address bar with new URL without hash or reloading the page

NOTE: You must take in consideration the possibility that the user disabled javascript.

There are techniques to show search engines that you have dynamic URLs. Usually you must have regular pages which will be pointed to the dynamic URLs. Here is the Google docs which describes how to create an website which uses AJAX in order to let the bots to crawl the pages: https://developers.google.com/webmasters/ajax-crawling/docs/learn-more

Community
  • 1
  • 1
Mihai Matei
  • 24,166
  • 5
  • 32
  • 50
  • Wow, you have really helped me. Can I ask you for one more thing, do you have any link on what to do in case if a person has disabled the javascript? – Johny Aug 12 '15 at 06:46
  • The best solution for this is to follow the docs from google. The link is in the answer. The idea is to create a regular website even if the audio will be stopped when reloading the page (If the user wants to listen all the playlist he will never reload the page) and to handle ajax requests if the javascript is enabled.. there are a lot of tutorials on google about this – Mihai Matei Aug 12 '15 at 06:49