locked
Song caching in windows store apps.

    Question

  • Hi All,

    I had developed music player which plays songs located at remote server.

    The app is working fine and users are also happy.

    I want to introduce and caching feature in my app.i.e once the song is streamed from the server then when user next time user plays the song it should not streamed from the server.

    This feature will considerably saves the user bandwidth.

    Can anyone guide me how do I implement this feature?

    For you information

    I am using audio tag of HTML 5 to play the music.

    Thank You.

    Tuesday, October 15, 2013 11:22 AM

Answers

  • Hi Ashwin,

    I think this feature should help you, take a look: Application Cache API. AppCache allows webpages to cache (or save) resources locally, including images, script libraries, style sheets, and so on. In addition, AppCache allows URLs to be served from cached content using standard Uniform Resource Identifier (URI) notation. 

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 16, 2013 1:09 AM
    Moderator
  • Perhaps you're saying that you want to be able to download the audio and play it from a local source, but of course in a pure streaming scenario (using an http:// URI as a source) you might get the audio in the INet cache, but it's not guaranteed to stay there. The same is true also of the HTML app cache, as there are limits as to how much space it will use (something like 10MB) and is subject to cleanup tools. Perhaps this is OK for your scenario, however, if you don't need everything cached.

    In Windows 8.1 you can also use the Windows.Networking.HttpClient API that gives you control over caching behavior.

    But perhaps you want to download tracks and save them more explicitly? In that case you can use the Background Transfer API (Windows.Networking.BackgroundTransfer) to start a download of the file into your local appdata folder, where you can then refer to it using an ms-appdata:///local/ URI in the audio.src tag, or into the music library (where you'll need to use URL.createObjectURL from the StorageFile). I believe that if you start the transfer--and you'd want to use the high priority setting in Windows 8.1 if you're targeting that platform--and have a progress handler to watch for a sufficient amount of streamed bytes, then you can start playback while the download is still finishing up. This way you're not really just caching, but building a music library.

    Wednesday, October 16, 2013 6:20 PM

All replies

  • Hi Ashwin,

    I think this feature should help you, take a look: Application Cache API. AppCache allows webpages to cache (or save) resources locally, including images, script libraries, style sheets, and so on. In addition, AppCache allows URLs to be served from cached content using standard Uniform Resource Identifier (URI) notation. 

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 16, 2013 1:09 AM
    Moderator
  • Perhaps you're saying that you want to be able to download the audio and play it from a local source, but of course in a pure streaming scenario (using an http:// URI as a source) you might get the audio in the INet cache, but it's not guaranteed to stay there. The same is true also of the HTML app cache, as there are limits as to how much space it will use (something like 10MB) and is subject to cleanup tools. Perhaps this is OK for your scenario, however, if you don't need everything cached.

    In Windows 8.1 you can also use the Windows.Networking.HttpClient API that gives you control over caching behavior.

    But perhaps you want to download tracks and save them more explicitly? In that case you can use the Background Transfer API (Windows.Networking.BackgroundTransfer) to start a download of the file into your local appdata folder, where you can then refer to it using an ms-appdata:///local/ URI in the audio.src tag, or into the music library (where you'll need to use URL.createObjectURL from the StorageFile). I believe that if you start the transfer--and you'd want to use the high priority setting in Windows 8.1 if you're targeting that platform--and have a progress handler to watch for a sufficient amount of streamed bytes, then you can start playback while the download is still finishing up. This way you're not really just caching, but building a music library.

    Wednesday, October 16, 2013 6:20 PM