Can you cache sound files in an iOS web app using a manifest or Web Storage?

后端 未结 3 1588
野性不改
野性不改 2021-02-09 08:28

When I add my beep-23.mp3 file to the cache manifest, the sound effect no longer works on or offline. Is this a bug, or am I doing something wrong?

The audio is within

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-09 08:44

    UPDATE for iOS 6:

    This is all fixed in iOS 6. You can cache an audio file and play it via javascript without user input.
    shaun5 Nov 7 '12 at 0:58


    Even though it should work and there are no specifications (W3C, Apple) which say it shouldn't, I tested some scenarios and it seems like Safari on iOS is just refusing to cache the sound files.

    Safari is loading the audio file (but not the index.html) every time I reload the page, so caching is apparently not working correct regardlessly of file size.

    After some research: It looks like it's not possible to cache audio files. So you may file a bug at Apples bugtracker.

    Here's my code to prove my results:

    index.html:

    
      
      
        
        
        
        
        Cached audio
      
      
        

    Cached audio

    audio.appcache:

    CACHE MANIFEST
    # 2012-02-23:v1
    
    # explicitly cached
    CACHE:
    index.html
    sample.mp3
    

    .htaccess:

    AddType text/cache-manifest .appcache
    AddType audio/mpeg .mp3
    

    EDIT

    I also tried using data URIs but, that Safari keeps refusing the audio data. So I think it's not possible to cache audio …

    
    ...
    
    ...
    

    EDIT 2

    Great idea, but it looks like it's not working … Safari for OS X -> ok; Safari for iOS -> still the same problem as we had before.

    
    ...
    
    ...
    
    

提交回复
热议问题