100 likes | 277 Vues
Media API. Web Science APT 2007/2008. John Meilak Reuben Sant Jason Farrugia. Introduction. Users demand rich multimedia capabilities Mobile hardware developed significantly Mobile devices are not simply used for voice calls and text messaging. Media Capabilities.
E N D
Media API Web Science APT 2007/2008 John Meilak Reuben Sant Jason Farrugia
Introduction • Users demand rich multimedia capabilities • Mobile hardware developed significantly • Mobile devices are not simply used for voice calls and text messaging
Media Capabilities • Play, stream and record media resources • Audio • Video • Face Detection • Used to adjust camera settings on face
android.media Package • Classes • MediaPlayer • MediaRecorder • FaceDetector • AudioSystem • Interfaces • MediaPlayer.OnBufferingUpdateListener • MediaPlayer.OnCompletionListener • MediaPlayer.OnErrorListener • MediaPlayer.OnPreparedListener
MediaPlayer Example • Local Resource MediaPlayer mp = MediaPlayer.create (context, R.raw.sound_1); • Stream mp.setDataSource(path); • Video mp.setDisplay(mPreview.getHolder().getSurface()); • An android.View.Surface is needed to display the video in it. • mPreview is of type android.view.SurfaceView which is defined in the xml layout file. • Playback mp.prepare(); mp.start();
MediaRecorder Example MediaRecorder rec = new MediaRecorder(); rec.setVideoSource(MediaRecorder.VideoSource.CAMERA); rec.setAudioSource(MediaRecorder.AudioSource.MIC); rec.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); rec.setVideoSize(400, 300); rec.setVideoFrameRate(24); rec.setVideoEncoder(MediaRecorder.VideoEncoder.H263); rec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); rec.setOutputFile(path); rec.prepare(); rec.start();
Supported Media Codecs • Audio • MP3compression scheme used to transfer audio files via internet and store in portable media players • AACadvanced audio coding, similar to mp3, used by iTunes • Ogg Vorbisa free and open source audio codec • MIDIused to describe a piece of music in enough detail to be able to reproduce it accurately • iMelodyringtone format • XMFextensible music format, used to keep file sizes as small as possible. used for polyphonic ringtones • RTTL/RTX ringtones format
Supported Media Codecs • Video • MPEG-4compression algorithm for graphics, audio and video • H.264simple standard providing good video quality at lower bit rates • 3GPsimplified version of mpeg used to accommodate limited bandwidth of mobile phones
References • http://code.google.com/android • http://www.helloandroid.com • http://davanum.wordpress.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/