22 static private class OrientationListener
extends OrientationEventListener
24 static public int deviceOrientation = 0;
26 public OrientationListener(Context
context)
32 public void onOrientationChanged(
int orientation)
34 if (orientation == ORIENTATION_UNKNOWN)
37 deviceOrientation = orientation;
41 static private Context m_context =
null;
42 static private OrientationListener m_orientationListener =
null;
43 private static final String QtTAG =
"Qt QtMultimediaUtils";
52 m_orientationListener =
new OrientationListener(
context);
59 static void enableOrientationListener(
boolean enable)
62 m_orientationListener.enable();
64 m_orientationListener.disable();
67 static int getDeviceOrientation()
69 return m_orientationListener.deviceOrientation;
72 static String getDefaultMediaDirectory(
int type)
74 String dirType =
new String();
77 dirType = Environment.DIRECTORY_MUSIC;
80 dirType = Environment.DIRECTORY_MOVIES;
83 dirType = Environment.DIRECTORY_DCIM;
94 path =
new File(Environment.getExternalStorageDirectory().getAbsolutePath()
95 + File.separator +
"Sounds");
97 path = Environment.getExternalStoragePublicDirectory(dirType);
102 return path.getAbsolutePath();
105 static void registerMediaFile(String
file)
107 MediaScannerConnection.scanFile(m_context,
new String[] {
file },
null,
null);
110 static File getCacheDirectory() {
return m_context.getCacheDir(); }
118 private static String[] getMediaCodecs()
120 final MediaCodecList codecList =
new MediaCodecList(MediaCodecList.REGULAR_CODECS);
121 final MediaCodecInfo[] codecInfoArray = codecList.getCodecInfos();
122 String[] codecs =
new String[codecInfoArray.length];
123 for (
int i = 0;
i < codecInfoArray.length; ++
i)
130 Uri parsedUri = Uri.parse(
url);
134 String scheme = parsedUri.getScheme();
135 if (scheme !=
null && scheme.contains(
"content")) {
136 ContentResolver cR =
context.getContentResolver();
137 type = cR.getType(parsedUri);
139 String
extension = MimeTypeMap.getFileExtensionFromUrl(
url);
141 type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
extension);
143 }
catch (Exception e) {
144 Log.e(QtTAG,
"getMimeType(): " + e.toString());