Media Supported File Format
Some tips/clues shown below can help you know why the newly-added file is not seen or cannot be played.
For videos, usually if the thumbnail of a file cannot be generated, it cannot be shown in Gallery or Video APP.
Related bugis: bug 942078
MDN: [https://developer.mozilla.org/en-US/docs/How_Mozilla_determines_MIME_Types Mozilla MIME Type}
Wikipedia: Internet Media Type
QA Test Plan: Media Playback Test Plan
- File Type Check
Files are categorized in 3 groups, pictures, music, and videos @http://dxr.mozilla.org/mozilla-central/source/toolkit/content/devicestorage.properties You need to check if your file extension is in the following list. Otherwise it will be not recognized as media files.- Pictures:
Format Media Type Implemented version .jpe .jpg .jpeg image/jpeg .gif image/gif .png image/png .bmp image/bmp - Music:
*.mp3; *.ogg; *.m4a; *.m4b; *.m4p; *.m4r; *.3gp; *.mp4; *.m3u; *.pls; *.opus; *.amr
Format Media Type Implemented version .mp4 .m4r .m4a .m4b .m4p audio/mp4 .mp3 .m3u audio/mpeg .ogg audio/ogg .opus audio/opus .3gp .amr audio/3gpp .pls audio/x-scpls .webm audio/webm - Videos:
*.mp4; *.mpeg; *.mpg; *.ogv; *.ogx; *.webm; *.3gp; *.ogg; *.m4v;
Format Media Type Implemented version .mp4 .m4v video/mp4 .mpeg .mpg video/mpeg .ogv .ogx .ogg video/ogg .webm video/webm .3gp .3g2 video/3gpp .mp4 video/mp4 .avi video/avi No video/quicktime No .mkv video/x-matroska No .wmv video/x-ms-wmv No .flv video/x-flv No
- MIME Type Get
For Gaia,
Before getting metadata and thumbnail then, canPlayType is used to check if it is valid video file by passing MIME type to gecko to check.
Gaia Code:
http://mxr.mozilla.org/gaia/source/apps/video/js/metadata.js#162
Gecko Code:
http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/HTMLMediaElement.cpp#2478 This MIME type is obtained from extension list extraMimeEntries @http://dxr.mozilla.org/mozilla-central/source/uriloader/exthandler/nsExternalHelperAppService.cpp#483
So if your file extension is not in the list. You will get a empty MIME. - Sniff
If you file passes those two checks explained above, it doesn't mean thumbnail can be generated or can be played successfully. Those checks only try to find a match in the mapping list of MIME and file extension.
In Gecko, DataSource(frameworks/base/media/libstagefright/DataSource.cpp sniff()) will sniff the files and try to find the corresponding extractor. You can find how many and which formats supported in RegisterDefaultSniffers(). - MIME mapper in Gaia
There is a mime and file extension mapping list in Gaia(http://mxr.mozilla.org/gaia/source/shared/js/mime_mapper.js). Currently this is used for those media files not in storage, like mail attachment. It can be used to get file extension by passing MIME type.
Basically B2G does "File Type Check" first for newly-added files, and then get the MIME type via a hardcoded file extension- mime type mapped list from nsExternalHelperAppService.cpp to pass it to a decoder created in DecoderTraits.cpp.