Multimedia.  Android provides built-in encoding/decoding for a variety of common media types  Allows you to play & record audio, still images & video.

Slides:



Advertisements
Similar presentations
What we will cover today… Where is the camera on my phone? Taking a photo Zoom in and out Deleting a photo Where do my photos go to? Viewing my photos.
Advertisements

- Rohit Vobbilisetty. What is the Camera API Capture Photos Capture Videos Camera API - Android2.
Cosc 5/4730 Multimedia Part 1: Audio media. PLAYING AUDIO Android android.media.
Group 8: Dylan Lentini (AE), Mandy Minuti (WSE), Jean Paul Galea (TL)
Cosc 5/4730 Android media Part 2: Pictures and Video.
Recording and playing audio. App Make app AudioFun with 4 buttons – Start recording (id=StartRecording) – Stop recording (id=StopRecording) – Start playback.
Programming with Android: Activities
Cannon Game 1 Fall 2014 CS7020: Game Design and Development.
Camera. Make new project – Give permission to use camera Make button called TakePicture Make button called ShowLastPic Add SurfaceView to layout – Surface.
Camera. Make new project – Give permission to use camera Make button called TakePicture Make button called ShowLastPic Add SurfaceView to layout – Surface.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
CS371m - Mobile Computing Audio.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Application Development Tutorial. Topics Lecture 5 Overview Overview of Networking Programming Tutorial 2: Downloading from the Internet.
Basic Audio and Video. Audio Primary components – Audio file stored in ‘raw’ folder within ‘res’ folder ‘raw’ directory must be created while many formats.
Multimedia.
Android – Camera –an Example
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Threads and Services. Background Processes One of the key differences between Android and iPhone is the ability to run things in the background on Android.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Standard Grade Presentations & Multimedia. Presentation & Multimedia Software Allows the user to set up exciting and attractive documents which helps.
1 Begin the editing process by selecting method of importing video Use the Movie Task Menu to import, edit and save video Follow this menu to complete.
Services A Service is an application component that can perform long-running operations in the background and does not provide a user interface. An application.
Camera. Make new project – CameraFun – Give permission to use camera write_external _storage Make two buttons – id takePictureButton – id showLastPicButton.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.
HTML5 Audio and Video. Slide 2 History Playing audio and video used to be something of a novelty You would embed a control (with the element) into your.
Maps Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
Mobile Device Development Camera and Sensors Dr.YingLiang Ma.
Persistence Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
Mobile Game Framework. Stuff You Should Know… Genres Paper Prototyping Mechanics Theme/Backstory Don’t Code!
Multimedia Capture & storage. Introduction A rich set of API for recording of audio & video. A developer has two choices  launch the built-in app using.
Camera. Make new project – Give permission to use camera Make button called TakePicture Make button called ShowLastPic Add SurfaceView to layout – Surface.
Android media Part 2: Pictures and Video
Android Application Lifecycle and Menus
A UGMENTED F UTURE OF M OBILE R EALITY Oleg Novosad Mobile / Web / Game Engineer.
Activities and Intents Richard S. Stansbury 2015.
CS378 - Mobile Computing Audio.
Android and s Ken Nguyen Clayton state University 2012.
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Multimedia. Audio,vedio and Images End user typically refer to vedio/audio using the respective file format MP4 or AVI(audio vedio interleave) Developer.
User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
8.実機で実行 8-1 カメラ・録音関係 1.写真の撮影 A. マニフェストの設定 【 AndroidManifest.xml 】 ・・・ "
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, WEB:
CS371m - Mobile Computing Audio. Audio on Device Devices have multiple audio streams: – music, alarms, notifications, incoming call ringer, in call volume,
Audio and Haptic Feedback
Android Application Audio 1.
Multimedia.
Activity and Fragment.
Camera.
GUI Programming Fundamentals
Lecture 7: Service Topics: Services, Playing Media.
Android – Event Handling
Mobile Software Development for Android - I397
CS499 – Mobile Application Development
Recap: Android Components
CIS 470 Mobile App Development
null, true, and false are also reserved.
CIS 136 Building Mobile Apps
Cannon Game App Android How to Program
Android Topics Custom ArrayAdapters Creating an Event Listener
Activities and Intents
ארועים ומאזינים android.
Lecture 7: Service Topics: Services, Broadcast Receiver, Playing Media.
SE4S701 Mobile Application Development
Activities, Fragments, and Intents
Presentation transcript:

Multimedia

 Android provides built-in encoding/decoding for a variety of common media types  Allows you to play & record audio, still images & video

 AudioManager  SoundPool  RingtoneManager & Ringtone  MediaPlayer  MediaRecorder  Camera

 Manages volume and ringer mode control  Loads & plays system sound effects  e.g., Key click,  Acquire AudioManager instance via  Context.getSystemService(Context.AUDIO_SERVICE)

 Manages & plays audio for applications  Can mix multiple audio clips and play them simultaneously

public class AudioVideoAudioManagerActivity extends Activity { private float volume = 0 ; private SoundPool soundPool; private int soundId; public void onCreate(Bundle savedInstanceState) {... final AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); audioManager.loadSoundEffects(); final TextView tv … volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); tv.setText(String.valueOf(volume)) …

final Button upButton = … upButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { … audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK, 1.0f ); } }); final Button playButton = … playButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { … soundPool.play(soundId, volume, volume, 1, 0, 1.0f ); } });

soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0 ); soundPool.setOnLoadCompleteListener( new OnLoadCompleteListener() { public void onLoadComplete( SoundPool soundPool,int sampleId,int status) { playButton.setEnabled(true); } }); soundId = soundPool.load(this, R.raw.sound, 1 ); } protected void onPause() { soundPool.unload(soundId); soundPool.release(); soundPool = null; super.onPause(); }

 RingtoneManager provides access to audio clips used for ringtones, notifications, alarms, etc.  Manages querying multiple media providers for audio clips ▪ getCursor () returns a Cursor for accessing available ringtones

public class AudioVideoRingtoneManagerActivity extends Activity { public void onCreate(Bundle savedInstanceState) { … final Button ringtoneButton = … ringtoneButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Ringtone r = RingtoneManager.getRingtone (AudioVideoRingtoneManagerActivity.this, Settings.System.DEFAULT_RINGTONE_URI); if (null != r) r.play(); } }); …

 Similar code for notification & alarm ringtones  Settings.System.DEFAULT_NOTIFICATION_URI  Settings.System.DEFAULT_ALARM_ALERT_URI

 Controls playback of audio/video files & streams  Allows greater control over stream playback  start(), stop, pause(), seekTo()

 Operation based on a state machine  See documentation  Some key steps  setDataSource()  prepare()  start()  pause(), seekTo()  stop()  release()

 View for displaying video files  Can load video from multiple sources  Provides various display options & convenience functions

public class AudioVideoVideoPlayActivity extends Activity { … public void onCreate(Bundle savedInstanceState) { … videoButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { videoView.setMediaController( new MediaController(AudioVideoVideoPlayActivity.this)); videoView.setVideoURI(Uri.parse(/* video URI */)); videoView.start(); } }); …

protected void onPause() { if (videoView != null && videoView.isPlaying()) { videoView.stopPlayback(); videoView = null; } super.onPause(); } …

 Used to record audio and video  Operation based on a state machine  See documentation  Some key steps  setAudioSource()/setVideoSource()  setOutputFormat(), …  prepare(), start()  stop(), release()

public class AudioRecordingActivity extends Activity { … private MediaRecorder mRecorder = null; … private void startRecording() { mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat ( MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setOutputFile(mFileName); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); try { mRecorder.prepare(); } catch (IOException e) {} mRecorder.start(); } …

private void stopRecording() { mRecorder.stop(); mRecorder.release(); mRecorder = null; }

 Used to  Manage image capture settings  Start/stop preview  Take pictures  etc.  Client for the Camera service, which manages the actual camera hardware

 Get Camera instance  Set Camera parameters as necesssary  Setup preview display  Start the preview  Take a picture & process image data  Release the Camera when not in use

public class AudioVideoCameraActivity extends Activity { … public void onCreate(Bundle savedInstanceState) { … getWindow().setFormat(PixelFormat.TRANSLUCENT); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); SurfaceView mSurfaceView = … SurfaceHolder mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(mSurfaceHelper); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }

protected void onPause() { super.onPause(); mCamera.release(); mCamera = null; } protected void onResume() { super.onResume(); mCamera = Camera.open(); } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); }

public void surfaceCreated(SurfaceHolder holder) { mCamera = Camera.open(); } public void surfaceDestroyed(SurfaceHolder holder) { mCamera.stopPreview(); mPreviewRunning = false; mCamera.release(); }

SurfaceHolder.Callback mSurfaceHelper = new SurfaceHolder.Callback() { boolean mPreviewRunning = false; LinearLayout mFrame = null; public void surfaceChanged(SurfaceHolder hldr, int fmt, int w,int h) { if (mPreviewRunning) mCamera.stopPreview(); Camera.Parameters p = mCamera.getParameters(); p.setPreviewSize(w, h); mCamera.setParameters(p); try { mCamera.setPreviewDisplay(holder); } catch (IOException e) { … } mCamera.startPreview(); mPreviewRunning = true; mFrame = (LinearLayout) findViewById(R.id.frame); mFrame.setOnTouchListener(mTouchHelper); } …

public void surfaceDestroyed(SurfaceHolder holder) { mPreviewRunning = false; if (null != mCamera) { mCamera.stopPreview(); mCamera.release(); } };

Camera.ShutterCallback mShutterCallback = new Camera.ShutterCallback() { public void onShutter() { // do something } }; Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { // do something } };

View.OnTouchListener mTouchHelper = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { mCamera.takePicture(mShutterCallback, null, mPictureCallback); return true; } }; }