TPESystem/Media/MediaSupportFileFormat: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 1: Line 1:
===Media Supported File Format===
===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.  
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.  
For videos, usually if the thumbnail of a file cannot be generated. It cannot be shown in Gallery or Video APP.
Related bugs: {{bug|942078}}
Related bugs: {{bug|942078}}


#'''File Type Check'''  
#''' File Type Check'''  
Files are categorized in 3 groups, pictures, music, and videos @gecko/toolkit/content/devicestorage.properties.  
Files are categorized in 3 groups, pictures, music, and videos @gecko/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.  
You need to check if your file extension is in the following list. Otherwise it will be not recognized as media files.
*Pictures:  
#* Pictures:
"*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp;"
''*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp;''
*Music:
#* Music:
"*.mp3; *.ogg; *.m4a; *.m4b; *.m4p; *.m4r; *.3gp; *.mp4; *.m3u; *.pls; *.opus; *.amr;"
''*.mp3; *.ogg; *.m4a; *.m4b; *.m4p; *.m4r; *.3gp; *.mp4; *.m3u; *.pls; *.opus; *.amr;''
*Videos:
#* Videos:
"*.mp4; *.mpeg; *.mpg; *.ogv; *.ogx; *.webm; *.3gp; *.ogg; *.m4v;"
''*.mp4; *.mpeg; *.mpg; *.ogv; *.ogx; *.webm; *.3gp; *.ogg; *.m4v;''
#'''MIME Type Get'''
#'''MIME Type Get'''  
For Gaia, <br>
For Gaia, <br>
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. <br>  
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. <br>  
Line 24: Line 23:
This MIME type is obtained from extension list extraMimeEntries @http://dxr.mozilla.org/mozilla-central/source/uriloader/exthandler/nsExternalHelperAppService.cpp#483 <br>  
This MIME type is obtained from extension list extraMimeEntries @http://dxr.mozilla.org/mozilla-central/source/uriloader/exthandler/nsExternalHelperAppService.cpp#483 <br>  
So if your file extension is not in the list. You will get a empty MIME.  
So if your file extension is not in the list. You will get a empty MIME.  
#'''Sniff'''  
#'''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. <br>  
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. <br>  
In Gecko, DataSource will sniff the files and try to find the corresponding extractor.
In Gecko, DataSource will sniff the files and try to find the corresponding extractor.

Revision as of 10:06, 20 December 2013

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 bugs: bug 942078

  1. File Type Check

Files are categorized in 3 groups, pictures, music, and videos @gecko/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:

*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp;

    • Music:

*.mp3; *.ogg; *.m4a; *.m4b; *.m4p; *.m4r; *.3gp; *.mp4; *.m3u; *.pls; *.opus; *.amr;

    • Videos:

*.mp4; *.mpeg; *.mpg; *.ogv; *.ogx; *.webm; *.3gp; *.ogg; *.m4v;

  1. 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.

  1. 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 will sniff the files and try to find the corresponding extractor.