John Meilak Reuben Sant Jason Farrugia Media API Web Science APT 2007/2008
Media API Introduction Users demand rich multimedia capabilities Mobile hardware developed significantly Mobile devices are not simply used for voice calls and text messaging
Media API Media Capabilities Play, stream and record media resources Audio Video Face Detection Used to adjust camera settings on face
Media API android.media Package Classes MediaPlayer MediaRecorder FaceDetector AudioSystem Interfaces MediaPlayer.OnBufferingUpdateListener MediaPlayer.OnCompletionListener MediaPlayer.OnErrorListener MediaPlayer.OnPreparedListener
Media API 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();
Media API 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();
Media API Supported Media Codecs Audio –MP3 compression scheme used to transfer audio files via internet and store in portable media players –AAC advanced audio coding, similar to mp3, used by iTunes –Ogg Vorbis a free and open source audio codec –MIDI used to describe a piece of music in enough detail to be able to reproduce it accurately –iMelody ringtone format –XMF extensible music format, used to keep file sizes as small as possible. used for polyphonic ringtones –RTTL/RTX ringtones format
Media API Supported Media Codecs Video –MPEG-4 compression algorithm for graphics, audio and video –H.264 simple standard providing good video quality at lower bit rates –3GP simplified version of mpeg used to accommodate limited bandwidth of mobile phones
Media API References videomusic-player-sample-from-local-disk-as- well-as-remote-urls/
Media API