SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
Android Media
(Audio & Video)
Topics
• Audio/Video support in Android platform
• Audio and Video playback
• Playing JET content
• Supported media formats
• Capturing audio
Audio and Videod Video
Support in Android Platform
Audio & Video Support in Android
• The Android platform offers built-in
encoding/decoding for a variety of common
media types, so that you can easily integrate
audio, video, and images into your applications.
• Accessing the platform's media capabilities is
fairly straightforward — you do so using the
same intents and activities mechanism that the
rest of Android uses.
Audio and Video
Playback
Audio and Video Playback
• Media can be played from
> A raw resource
> A file from the system
> Network stream
• You can play back the audio data only to the
standard output device; currently, that is the
mobile device speaker or Bluetooth headset.
• You cannot play sound files in the conversation
audio.
Play from a Raw Resource
• Play back media (notably sound) within your
own applications.
• Steps to take
> Put the sound (or other media resource) file into
the /res/raw folder of your project, where the Eclipse
plugin (or aapt) will find it and make it into a
resource that can be referenced from your R class
> Create an instance of MediaPlayer, referencing that
resource using MediaPlayer.create, and then call
start() on the instance:
MediaPlayer mp = MediaPlayer.create(context,
R.raw.sound_file_1);
mp.start();
Playing from a File or Stream
• You can play media files from the filesystem or
a web URL
• Steps to take
> Create an instance of the MediaPlayer
> Call setDataSource() with a String containing the
path (local filesystem or URL) to the file you want to
play
> Call prepare() then start() on the instance:
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE);
mp.prepare();
mp.start();
Playing JET Content
Playing JET Content
• The Android platform includes a JET engine that
lets you add interactive playback of JET audio
content in your applications.
• You can create JET content for interactive
playback using the JetCreator authoring
application that ships with the SDK.
• To play and manage JET content from your
application, use the JetPlayer class.
Playing JET Content
• A example of how to set up JET playback from a
.jet file stored on the SD card:
JetPlayer myJet = JetPlayer.getJetPlayer();
myJet.loadJetFile("/sdcard/level1.jet");
byte segmentId = 0;
// queue segment 5, repeat once, use General MIDI,
transpose by -1 octave
myJet.queueJetSegment(5, -1, 1, -1, 0, segmentId++);
// queue segment 2
myJet.queueJetSegment(2, -1, 0, 0, 0, segmentId++);
myJet.play();
Android Supported
Media Formats
Core Media Formats
• Audio
> AAC LC/LTP, HE-AACv1 (AAC+), HE-AACv2 (enhanced
AAC+), AMR-NB, AMR-WB, MP3, MIDI, Ogg Vorbis,
PCM/WAVE
• Video
> H.263, H.264 AVC, MPEG-4 SP
Audio Capture
Audio Capture
• The Android platform lets you record audio and
video, where supported by the mobile device
hardware.
• To record audio or video, use the
MediaRecorder class.
Audio Capture Example
recorder = new MediaRecorder();
ContentValues values = new ContentValues(3);
values.put(MediaStore.MediaColumns.TITLE, SOME_NAME_HERE);
values.put(MediaStore.MediaColumns.TIMESTAMP, System.currentTimeMillis());
values.put(MediaStore.MediaColumns.MIME_TYPE, recorder.getMimeContentType());
ContentResolver contentResolver = new ContentResolver();
Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI;
Uri newUri = contentResolver.insert(base, values);
if (newUri == null) {
// need to handle exception here - we were not able to create a new
// content entry
}
String path = contentResolver.getDataFilePath(newUri);
// could use setPreviewDisplay() to display a preview to suitable View here
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaEdureka!
 
android media player project proposal
android media player project proposalandroid media player project proposal
android media player project proposalMuhammad Usman
 
Android chapter02-setup2-emulator
Android chapter02-setup2-emulatorAndroid chapter02-setup2-emulator
Android chapter02-setup2-emulatorguru472
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecturedeepakshare
 
Android Architecture.pptx
Android Architecture.pptxAndroid Architecture.pptx
Android Architecture.pptxpriya Nithya
 
Android Programming Seminar
Android Programming SeminarAndroid Programming Seminar
Android Programming SeminarNhat Nguyen
 

Was ist angesagt? (20)

Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | Edureka
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
android media player project proposal
android media player project proposalandroid media player project proposal
android media player project proposal
 
Android chapter02-setup2-emulator
Android chapter02-setup2-emulatorAndroid chapter02-setup2-emulator
Android chapter02-setup2-emulator
 
Introduction to Eclipse IDE
Introduction to Eclipse IDEIntroduction to Eclipse IDE
Introduction to Eclipse IDE
 
Deep Dive into the AOSP
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSP
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Android 11
Android 11Android 11
Android 11
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 
Android Architecture.pptx
Android Architecture.pptxAndroid Architecture.pptx
Android Architecture.pptx
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Android Programming Seminar
Android Programming SeminarAndroid Programming Seminar
Android Programming Seminar
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 

Ähnlich wie Android media

Android Multimedia Player Project Presentation
Android Multimedia Player Project PresentationAndroid Multimedia Player Project Presentation
Android Multimedia Player Project PresentationRashmi Gupta
 
Java Media Framework API
Java Media Framework APIJava Media Framework API
Java Media Framework APIelliando dias
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)Khaled Anaqwa
 
Prasentation Managed DirectX
Prasentation Managed DirectXPrasentation Managed DirectX
Prasentation Managed DirectXA. LE
 
Paris Video Tech #2 - Presentation by Jean-Yves Avenard
Paris Video Tech #2 - Presentation by Jean-Yves AvenardParis Video Tech #2 - Presentation by Jean-Yves Avenard
Paris Video Tech #2 - Presentation by Jean-Yves AvenardErica Beavers
 
Ig2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martinIg2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martinKalen612
 
Ig2 task 1 work sheet (use this)
Ig2 task 1 work sheet (use this)Ig2 task 1 work sheet (use this)
Ig2 task 1 work sheet (use this)Deightonater
 
Audio and video streaming
Audio and video streamingAudio and video streaming
Audio and video streamingRohan Bhatkar
 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSLYoss Cohen
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheetgordonpj96
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
Ben white ig2 task 1 work sheet
Ben white   ig2 task 1 work sheetBen white   ig2 task 1 work sheet
Ben white ig2 task 1 work sheetBenWhite101
 
Core audio
Core audioCore audio
Core audioscussen
 
How to make a video - Part 2: Post-Production Basics
How to make a video - Part 2: Post-Production BasicsHow to make a video - Part 2: Post-Production Basics
How to make a video - Part 2: Post-Production BasicsKris Brewer
 

Ähnlich wie Android media (20)

Android Multimedia Support
Android Multimedia SupportAndroid Multimedia Support
Android Multimedia Support
 
Android Multimedia Player Project Presentation
Android Multimedia Player Project PresentationAndroid Multimedia Player Project Presentation
Android Multimedia Player Project Presentation
 
Android media-chapter 23
Android media-chapter 23Android media-chapter 23
Android media-chapter 23
 
Gtug
GtugGtug
Gtug
 
Java Media Framework API
Java Media Framework APIJava Media Framework API
Java Media Framework API
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)
 
Prasentation Managed DirectX
Prasentation Managed DirectXPrasentation Managed DirectX
Prasentation Managed DirectX
 
Paris Video Tech #2 - Presentation by Jean-Yves Avenard
Paris Video Tech #2 - Presentation by Jean-Yves AvenardParis Video Tech #2 - Presentation by Jean-Yves Avenard
Paris Video Tech #2 - Presentation by Jean-Yves Avenard
 
Ig2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martinIg2 task 1 work sheet connor martin
Ig2 task 1 work sheet connor martin
 
Ig2 task 1 work sheet (use this)
Ig2 task 1 work sheet (use this)Ig2 task 1 work sheet (use this)
Ig2 task 1 work sheet (use this)
 
Audio and video streaming
Audio and video streamingAudio and video streaming
Audio and video streaming
 
Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSL
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
BDPA Open Source 2012
BDPA  Open Source  2012BDPA  Open Source  2012
BDPA Open Source 2012
 
Ben white ig2 task 1 work sheet
Ben white   ig2 task 1 work sheetBen white   ig2 task 1 work sheet
Ben white ig2 task 1 work sheet
 
IG2 Task 1 Work Sheet
IG2 Task 1 Work SheetIG2 Task 1 Work Sheet
IG2 Task 1 Work Sheet
 
Core audio
Core audioCore audio
Core audio
 
How to make a video - Part 2: Post-Production Basics
How to make a video - Part 2: Post-Production BasicsHow to make a video - Part 2: Post-Production Basics
How to make a video - Part 2: Post-Production Basics
 
Html multimedia
Html multimediaHtml multimedia
Html multimedia
 

Mehr von Krazy Koder (20)

2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xc
2310 b xc2310 b xc
2310 b xc
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
 
2310 b 17
2310 b 172310 b 17
2310 b 17
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 14
2310 b 142310 b 14
2310 b 14
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
2310 b 12
2310 b 122310 b 12
2310 b 12
 
2310 b 11
2310 b 112310 b 11
2310 b 11
 
2310 b 10
2310 b 102310 b 10
2310 b 10
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 

Android media

  • 2. Topics • Audio/Video support in Android platform • Audio and Video playback • Playing JET content • Supported media formats • Capturing audio
  • 3. Audio and Videod Video Support in Android Platform
  • 4. Audio & Video Support in Android • The Android platform offers built-in encoding/decoding for a variety of common media types, so that you can easily integrate audio, video, and images into your applications. • Accessing the platform's media capabilities is fairly straightforward — you do so using the same intents and activities mechanism that the rest of Android uses.
  • 6. Audio and Video Playback • Media can be played from > A raw resource > A file from the system > Network stream • You can play back the audio data only to the standard output device; currently, that is the mobile device speaker or Bluetooth headset. • You cannot play sound files in the conversation audio.
  • 7. Play from a Raw Resource • Play back media (notably sound) within your own applications. • Steps to take > Put the sound (or other media resource) file into the /res/raw folder of your project, where the Eclipse plugin (or aapt) will find it and make it into a resource that can be referenced from your R class > Create an instance of MediaPlayer, referencing that resource using MediaPlayer.create, and then call start() on the instance: MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1); mp.start();
  • 8. Playing from a File or Stream • You can play media files from the filesystem or a web URL • Steps to take > Create an instance of the MediaPlayer > Call setDataSource() with a String containing the path (local filesystem or URL) to the file you want to play > Call prepare() then start() on the instance: MediaPlayer mp = new MediaPlayer(); mp.setDataSource(PATH_TO_FILE); mp.prepare(); mp.start();
  • 10. Playing JET Content • The Android platform includes a JET engine that lets you add interactive playback of JET audio content in your applications. • You can create JET content for interactive playback using the JetCreator authoring application that ships with the SDK. • To play and manage JET content from your application, use the JetPlayer class.
  • 11. Playing JET Content • A example of how to set up JET playback from a .jet file stored on the SD card: JetPlayer myJet = JetPlayer.getJetPlayer(); myJet.loadJetFile("/sdcard/level1.jet"); byte segmentId = 0; // queue segment 5, repeat once, use General MIDI, transpose by -1 octave myJet.queueJetSegment(5, -1, 1, -1, 0, segmentId++); // queue segment 2 myJet.queueJetSegment(2, -1, 0, 0, 0, segmentId++); myJet.play();
  • 13. Core Media Formats • Audio > AAC LC/LTP, HE-AACv1 (AAC+), HE-AACv2 (enhanced AAC+), AMR-NB, AMR-WB, MP3, MIDI, Ogg Vorbis, PCM/WAVE • Video > H.263, H.264 AVC, MPEG-4 SP
  • 15. Audio Capture • The Android platform lets you record audio and video, where supported by the mobile device hardware. • To record audio or video, use the MediaRecorder class.
  • 16. Audio Capture Example recorder = new MediaRecorder(); ContentValues values = new ContentValues(3); values.put(MediaStore.MediaColumns.TITLE, SOME_NAME_HERE); values.put(MediaStore.MediaColumns.TIMESTAMP, System.currentTimeMillis()); values.put(MediaStore.MediaColumns.MIME_TYPE, recorder.getMimeContentType()); ContentResolver contentResolver = new ContentResolver(); Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI; Uri newUri = contentResolver.insert(base, values); if (newUri == null) { // need to handle exception here - we were not able to create a new // content entry } String path = contentResolver.getDataFilePath(newUri); // could use setPreviewDisplay() to display a preview to suitable View here recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start();