Professional Documents
Culture Documents
Multimedia in Android
Tagele B.
1
Multimedia Techniques
The Android platform provides comprehensive
multimedia functionality.
techniques to manipulate
images,
record and play back audio,
and record and play back video.
An application that records any type of media
requires setting the appropriate permission
in the AndroidManifest.xml file (one or both of
the following):
<uses-permission
android:name="android.permission.RECORD_AUDI
O"/>
<uses-permission
android:name="android.permission.RECORD_VIDE 2
Images
Images local to an application are usually put in
the res/drawable/ directory, They can be
accessed with the appropriate resource identifier,
such as R.drawable.my_picture.
Images on the Android device filesystem can be
accessed using the
normal Java classes, such as an InputStream.
However, the preferred method in Android to read
5
Other methods of MediaPlayer
class
isPlaying()
This method just returns true/false indicating the song is
playing or not
seekTo(positon)
This method takes an integer, and move song to that
particular second
getCurrentDuration()
This method returns the current position of song in
milliseconds
getDuration()
This method returns the total time duration of song in
milliseconds
release()
This method releases any resource attached with
MediaPlayer object
setVolume(float leftVolume, float 6
Contd..
selectTrack(int index)
This method takes an integer, and select the track from
the list on that particular index
getTrackInfo()
This method returns an array of track information
Example
Here is an example demonstrating the use of
MediaPlayer class. It creates a basic media player
that allows you to
forward,
backward,
play and
pause a song.
Note: for this application to work you need 7
8
Media_player.xml
9
10
11
12
13
Animation in Android (Tween
Animation)
Tween Animation takes some parameters such as
start value, end value, size, time duration,
rotation angle etc. and perform the required
animation on that object.
It can be applied to any type of object. So in order
to use this, android has provided us a class called
Animation.
In order to perform animation in android, we are
going to call a static function loadAnimation() of
the class AnimationUtils. We are going to receive
the result in an instance of Animation Object. Its
syntax is as follows:
Animation animation =
AnimationUtils.loadAnimation
(getApplicationContext(), 14
Functions(methods) of
animation class
start()
This method starts the animation.
setDuration(long duration)
This method sets the duration of an animation.
getDuration()
This method gets the duration which is set by
above method.
end()
This method ends the animation.
cancel()
This method cancels the animation.