Search code examples
flashaudio

is it possible to detect if a flash movie also contains (plays) sound?


Is there a way to detect if a flash movie contains any sound or is playing any music?
It would be nice if this could be done inside a webbrowser (actionscript from another flash object, javascript,..) and could be done before the flash movie starts playing.

However, I have my doubts this will be possible altogether, so any other (programmable) solution is also appreciated


Solution

  • Yes, on the server side for sure. Client side? I don't know. (I'm a serverside kind of guy.)

    On the server side, one would have to parse the file, read the header and/or look for audio frames. (I've ported a haskel FLV parser to Java for indexing purposes myself, and there are other parsing utilities out there. It is possible.)

    osflash.org's FLV page has the gory details. Check out the FLV Format sections's FLV Header table.

    FIELD       DATA TYPE      EXAMPLE                  DESCRIPTION
     Signature   byte[3]        “FLV”                    Always “FLV”
     Version     uint8          “\x01” (1)               Currently 1 for known FLV files
     Flags       uint8 bitmask  “\x05” (5, audio+video)  Bitmask: 4 is audio, 1 is video
     Offset      uint32-be      “\x00\x00\x00\x09” (9)   Total size of header (always 9 for known FLV files) 
    

    EDIT: My client side coding with Flash is non-existent, but I believe there is an onMetaDataLoad event that your code could catch. That might be happening a bit late for you, but maybe it is good enough?