3.8 KiB
Android tutorial 5: A Complete media player
Goal!
This tutorial wants to be the “demo application” that showcases what can be done with GStreamer in the Android platform.
It is intended to be downloaded in final, compiled, form rather than analyzed for its pedagogical value, since it adds very little GStreamer knowledge over what has already been shown in .
FIXME: Do we want to provide a binary of the app?
Introduction
The previous tutorial already implemented a basic media player. This one simply adds a few finishing touches. In particular, it adds the capability to choose the media to play, and disables the screensaver during media playback.
These are not features directly related to GStreamer, and are therefore outside the scope of these tutorials. Only a few implementation pointers are given here.
Registering as a media player
The AndroidManifest.xml tells the Android system the capabilities of
the application. By specifying in the intent-filter of the activity
that it understands the audio/*, video/* and image/* MIME types,
the tutorial will be offered as an option whenever an application
requires such medias to be viewed.
“Unfortunately”, GStreamer knows more file formats than Android does,
so, for some files, Android will not provide a MIME type. For these
cases, a new intent-filter has to be provided which ignores MIME types
and focuses only in the filename extension. This is inconvenient because
the list of extensions can be large, but there does not seem to be
another option. In this tutorial, only a very short list of extensions
is provided, for simplicity.
Finally, GStreamer can also playback remote files, so URI schemes like
http are supported in another intent-filter. Android does not
provide MIME types for remote files, so the filename extension list has
to be provided again.
Once we have informed the system of our capabilities, it will start
sending
Intents
to invoke our activity, which will contain the desired URI to play. In
the onCreate() method the intent that invoked the activity is
retrieved and checked for such URI.
Implementing a file chooser dialog
The UI includes a new button 