13 Replies Latest reply on Mar 26, 2007 1:08 AM by GregConnTelevirtual

    can flash store files within itself?

    GregConnTelevirtual Level 1
      Hi i have an SWF which plays mp3s from a remote server. The mp3s are generated by the server and updated on an irregular basis. What I'd like the SWF to do is play the mp3 from the server only when the mp3 is new i.e. not updated. I've made a text file with a timecode in it, when the mp3 is updated the timecode is updated also, the SWF will check the text file if the timecode is different to the previous timecode then i want it to go to the server and play the new mp3 BUT if the timecode is the same I'd like it play a cached version of the mp3 i.e. not go to the server at all hence making the server do less work.

      So really my question is can you play an mp3 from a server and get the flash to store it so if you want to play it again you dont play it from the server?

      right i think that all makes sense, hope someone can help.

      cheers

      Greg
        • 1. Re: can flash store files within itself?
          Greg Dove Level 4
          If you're reading the timecode from the text file you could try appending the value you read to the mp3 url you request each time, which should maximise use of the local cache copy depending on the users browser settings.

          "mymp3name.mp3?timecode="+timecode

          where the timecode variable is the timecode you loaded previously.

          I did this recently with an xml file that was being updated on the server by appending a random number to avoid the browser cache. In your case, you want to keep using the cached version unless the timecode changes so I think this should work so long as the name of the mp3 file is not altered for subsequent requests.
          • 2. Re: can flash store files within itself?
            GregConnTelevirtual Level 1
            See this I've already done because good old internet explorer automatically tries to play from it's cache and for some reason doesn't work when it does this so i'm ahving to stick the a random number at the end of the url so it always looks for a new one and this is why i need the flash to cache it not the browser. I want the SWF to do the work not the browser or the Server...........is it possible?
            • 3. Re: can flash store files within itself?
              Greg Dove Level 4
              I'm pretty sure you can't get flash to do that. The only thing you can save are local SharedObjects.

              I haven't tried what you're trying to do which is prefer the local cache on designated occasions, by using an appended identical parameter. I've always done it with random parameters to try to avoid the cache. But it was the only thing I could think of sorry.
              • 4. Re: can flash store files within itself?
                Greg Dove Level 4
                Any chance you could have a different filename of the mp3 whenever it changes on the server side... and have that loaded from the textfile? As well as the timecode if you need it.
                • 5. Re: can flash store files within itself?
                  Greg Dove Level 4
                  to clarify my last post: if the appended parameter seems to force a download even if its identical to the last time... then maybe avoid the need to use the appended parameter. Or is this the "server doing the work" that you referred to in your last post?
                  • 6. Re: can flash store files within itself?
                    GregConnTelevirtual Level 1
                    Yeah basically i think you're almost as confused as me! We need the server to do as little work as possible because we have a lot of users, the appended parameter on the URL forces the browser to always go to the server so we cant do that but internet explorer doesnt work when it plays it's cached files so we cant do that, so this is the only thing we've come up with. I found this on the knowledge base

                    saving files locally

                    which may work but i really dont want to be dumping things on users computers as i hate it when sites do that to me!

                    cheers for trying though

                    Greg
                    • 7. Re: can flash store files within itself?
                      Greg Dove Level 4
                      I am frequently confused. But I do understand what you want to do even if I don't have the answer. I don't think Central will help you as I'm pretty sure its a little different to flash and I think its been superseded by Apollo very recently.

                      I can't understand why the URL request with the identical parameter would not maximise use of local browser caches. This is not from experience unfortunately.. just the observation that people go to great (well maybe not great) lengths to provider random parameters to avoid cacheing ... in other words ensuring that they use different parameters each time to force a new load from the server. Beyond that the individual browser settings of different users of IE or firefox etc will always presumably have an effect.

                      In the absence of a solution for you, all I can suggest is trying something a little weird and maybe using LoadVars to "load" your mp3 and see if it works differently. I have no idea if it might help. I'd never heard of this before but read about it just now here:

                      http://www.actionscript.com/Article/tabid/54/ArticleID/Preloading-Files-into-the-Browser-s -Cache/Default.aspx
                      • 8. Re: can flash store files within itself?
                        kglad Adobe Community Professional & MVP
                        don't append a random number to your mp3's file name. just append the time code (or some part of it) so the mp3 name stays the same unless the time code changes.
                        • 9. Re: can flash store files within itself?
                          Greg Dove Level 4
                          kglad:

                          Do you mean what I put in my first post..? He said he already tried that.
                          • 10. Re: can flash store files within itself?
                            Greg Dove Level 4
                            GregConnTelevirtual :

                            Can you post the actionscript loadVars code that reads the timeCode from the text file ...? Oh and for reading the text file... for that you probably do want to append a random number or getTimer code. You want to d/l the text file each time for sure and don't want that to load from the cache.

                            Try using trace on the timecode that you append to the URL for the mp3 and make sure its correct.

                            The only other thing I can think of (and please don't take offence, just trying to eliminate everything): For the testing you're doing, what are the browser cache settings?
                            • 11. Re: can flash store files within itself?
                              kglad Adobe Community Professional & MVP
                              he may have said he tried it, but that wouldn't make sense. if a browser encounters two files have the same name (with an appended string or without an appended string), the 2nd encountered file will be retrieved from the user's cache.
                              • 12. Re: can flash store files within itself?
                                Greg Dove Level 4
                                kglad:

                                Thanks. That's what I thought too... and all I could think of beyond that was what I put in my last post... i.e. for some reason the appended string is getting a different value every time or... the browser cache settings on the test machine are set to always check the server.
                                • 13. Re: can flash store files within itself?
                                  GregConnTelevirtual Level 1
                                  Thanks for all the replies guys I've been away from my desk all weekend hence not replying!

                                  I will post up the code of getting the timecode as soon as I've written it as I'm currently doing it a slightly different way.

                                  In response the browser cache settings i don't want to touch them as what I've made is to be rolled out to the public and i don't want to make regular users mess around with their settings, so that rules that out.