R
R
Rokis2017-07-30 14:36:23
Audio
Rokis, 2017-07-30 14:36:23

How to upload music to the user when visiting the page?

Hello.
Description:
There is a script for playing .ogg files. The files themselves are stored in a separate folder on the site. With a certain action (click / time), a request is made to these files, they are loaded and played.
Task:
Make sure that these files are loaded (not played back) to the user immediately (when entering the page), and not only after a certain action.
Meaning:
For the user to visit the site once and then be able to listen to all the audio without connecting to the Internet, by the same call through the script on the site.
It must be something simple to do.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-07-30
@Rokis

It must be something simple to do.
Not much, really.
The simplest thing is to make an ajax request to these files and cache headers to tell the browser to save them. In this case, subsequent requests will be processed from the cache. But there are several problems:
The listed problems are solved by Service Worker , but its implementation, especially in this context, is not trivial. Suffice it to say that Paul Lewis devoted 15 videos to this task . True, he made a video player, but making an audio player is not much easier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question