Multimedia.

Slides:



Advertisements
Similar presentations
10.2. Audio with SD Card Prof. Oum Saokosal Master of Engineering in Information Systems, South Korea
Advertisements

Using Multimedia on the Web Enhancing a Web Site with Sound, Video, and Applets.
CNIT 132 – Week 9 Multimedia. Working with Multimedia Bandwidth is a measure of the amount of data that can be sent through a communication pipeline each.
Royalty Free Music for Schools Do You Have the To Do a Podcast?
Cosc 5/4730 Multimedia Part 1: Audio media. PLAYING AUDIO Android android.media.
It provides a framework for embedded multimedia facilities in java enabled mobile devices.
Group 8: Dylan Lentini (AE), Mandy Minuti (WSE), Jean Paul Galea (TL)
HTML 5 and CSS 3, Illustrated Complete Unit K: Incorporating Video and Audio.
Video Xiyang Song CGDD 4903.
Multimedia.  Android provides built-in encoding/decoding for a variety of common media types  Allows you to play & record audio, still images & video.
Cosc 5/4730 Android media Part 2: Pictures and Video.
Mobile Computing Lecture#13. Lecture Contents 2 Widgets  Creating App Widget  Unsupported/Supported Views/Layouts  Widget Layout  Widget Settings.
Chapter 6 Jam! Implementing Audio in Android Apps.
Chapter 6: Jam! Implementing Audio in Android Apps.
Recording and playing audio. App Make app AudioFun with 4 buttons – Start recording (id=StartRecording) – Stop recording (id=StopRecording) – Start playback.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
John Meilak Reuben Sant Jason Farrugia Media API Web Science APT 2007/2008.
Microsense Webcast Streaming Solutions
Debugging Android Applications
Slides prepared by Rose Williams, Binghamton University Chapter 10 File I/O.
CS371m - Mobile Computing Audio.
How to Play Movies in PowerPoint with the Windows Media Player Control.
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.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
INF Web Design Using Multimedia on the Web Sound - Part 2.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
Location Services: Part 1 (Location and Geocoding)
2.02G Publishing Animated Videos 2.02 Develop Computer Animations.
Networking: Part 2 (Accessing the Internet). The UI Thread When an application is launched, the system creates a “main” UI thread responsible for handling.
Data Storage: Part 4 (Content Providers). Content Providers Content providers allow the sharing of data between applications. Inter-process communication.
ScreenPlay Director Training By Erik Collett
Data Storage: Part 2 (File System). Internal Storage versus External Storage Internal storage − for private data –By default, files saved to the internal.
Media in PowerPoint Learning Goal: Today you are going to explore how music and video can be added to a presentation.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Outline Overview Video Format Conversion Connection with An authentication Streaming media Transferring media.
Networking: Part 1 (Web Content). Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine.
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.
New Activity On Button Click via Intent. App->res->Layout->Blank Activity A new xml file is created and a new class is added to java folder. In manifest.xml.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
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.
Android media Part 2: Pictures and Video
CS378 - Mobile Computing Audio.
Multimedia. Audio,vedio and Images End user typically refer to vedio/audio using the respective file format MP4 or AVI(audio vedio interleave) Developer.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Cosc 5/4735 YouTube API. YouTube The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications.
CHAPTER 8 Multimedia 1. Using Multimedia ❖ Multimedia: the combination of text, sound, and video to express an idea or convey a message. ❖ Podcasts: a.
Lecture 7: Media Player Topics: Media Player, Async prepare Date: Mar 3, 2016.
Streaming Media. What is Streaming Media The delivery of audio, video and other multimedia content across the internet using streaming media servers.
CS371m - Mobile Computing Audio. Audio on Device Devices have multiple audio streams: – music, alarms, notifications, incoming call ringer, in call volume,
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Audio and Haptic Feedback
Android Application Audio 1.
Interact 2: Options for organising and presenting content
Multimedia.
Java Examples Embedded System Software
Lecture 7: Service Topics: Services, Playing Media.
Android Boot Camp for Developers Using Java, 3E
Lecture 7: Media Player Topics: Media Player, Async prepare
Recap: Android Components
CIS 470 Mobile App Development
Android Sensor Programming
Android Topics Android Activity Lifecycle and Experiment Toast
Activities and Intents
CIS 470 Mobile App Development
Lecture 7: Service Topics: Services, Broadcast Receiver, Playing Media.
SE4S701 Mobile Application Development
Activities, Fragments, and Intents
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Multimedia

Audio and Video The Android platform offers built-in encoding/decoding for a variety of common media types. You can easily integrate audio, video, and images into your applications. You can play audio or video from media files stored in the application’s (raw) resources standalone files in the file system a data stream arriving over a network connection. To play audio or video, use the MediaPlayer class. Class VideoView simplifies embedding videos in an application. To record audio or video, use the MediaRecorder class. (not available in emulators) ©SoftMoore Consulting

Supported Media Formats Media Type Format File Type(s) Audio AAC/AAC+ .m4a, .3gp, .aac MPEG Audio .mp3, .mp4, PCM/WAVE .wav Ogg Vorbis .ogg MIDI .mid, .xmf, .mxmf AMR-NB/WB/AMR-WB .3gp Image JPEG .jpg GIF .gif PNG .png BMP .bmp Video H.263 .3gp and .mp4 H.264 AVC (Android 3.0+) MPEG-4 SP VP8 .WebM ©SoftMoore Consulting

Selected Methods from Class MediaPlayer Default constructor. static MediaPlayer create(Context context, int resid) Creates a MediaPlayer for a given resource id. static MediaPlayer create(Context context, Uri uri) Creates a MediaPlayer for a given Uri. void pause() Pauses playback. void release() Releases resources associated with this MediaPlayer object. ©SoftMoore Consulting

Selected Methods from Class MediaPlayer (continued) void setDataSource(String path) Sets the data source (file-path or http/rtsp URL) to use. void setDataSource(FileDescriptor fd) Sets the data source (FileDescriptor) to use. void setDataSource(Context context, Uri uri) Sets the data source as a content Uri. void setLooping(boolean looping) Sets the player to be looping or non-looping. void start() Starts or resumes playback. void stop() Stops playback after playback has been started or paused. ©SoftMoore Consulting

State Diagram for MediaPlayer ©SoftMoore Consulting

Example: Playing an Audio Resource File Create the directory (folder) res/raw if it does not already exist. Copy the audio file (e.g., echotaps.m4a) to the res/raw folder and the refresh the folder. Create activity and declare a MediaPlayer object. public class MainActivity extends ActionBarActivity { private MediaPlayer mediaPlayer; ... // continued on next page } ©SoftMoore Consulting

Example: Playing an Audio Resource File (in the onCreate() method) setVolumeControlStream(AudioManager.STREAM_MUSIC); Button playButton = (Button) findViewById(R.id.playButton); playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) if (mediaPlayer != null) mediaPlayer.release(); mediaPlayer = MediaPlayer.create(MainActivity.this, R.raw.echotaps); mediaPlayer.start(); } }); Note: No file extension. ©SoftMoore Consulting

Example: Playing an Audio Resource File (continued) Button stopButton = (Button) findViewById(R.id.stopButton); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) if (mediaPlayer != null) mediaPlayer.stop(); mediaPlayer.release(); mediaPlayer = null; } }); ©SoftMoore Consulting

Example: Playing an Audio Resource File (continued) @Override public void onPause() { super.onPause(); if (mediaPlayer != null) mediaPlayer.pause(); } public void onResume() super.onResume(); mediaPlayer.start(); ©SoftMoore Consulting

Example: Playing an Audio Resource File (continued) @Override public void onStop() { super.onStop(); if (mediaPlayer != null) mediaPlayer.stop(); mediaPlayer.release(); mediaPlayer = null; } ©SoftMoore Consulting

Example: Playing an Audio Resource File ©SoftMoore Consulting

Playing Audio from a File or Stream Create an instance of MediaPlayer using new. Call setDataSource() with a String containing the path (file system or URL) to the file you want to play. First prepare() then start() on the instance. Example MediaPlayer mp = new MediaPlayer(); mp.setDataSource(PATH_TO_FILE); mp.prepare(); mp.start(); ©SoftMoore Consulting

Playing Audio from a File or Stream (continued) Either IllegalArgumentException or IOException can be thrown by setDataSource() since the file may not exist. If the URL references an online media file, the file must be capable of progressive download. ©SoftMoore Consulting

Recording Audio Files: Permissions An application that records audio must set the appropriate permissions in the AndroidManifest.xml file. <uses-permission android:name= "android.permission.RECORD_AUDIO" /> If the audio is recorded on external storage, an additional permission is required. "android.permission.WRITE_EXTERNAL_STORAGE" /> ©SoftMoore Consulting

Recording Audio Files Create an instance of MediaRecorder. Set the audio source using MediaRecorder.setAudioSource(). usually MediaRecorder.AudioSource.MIC other possible sources include DEFAULT (equivalent to MIC), VOICE_CALL, and CAMCORDER. Set output file format using MediaRecorder.setOutputFormat(). e.g., to MediaRecorder.OutputFormat.THREE_GPP other possible formats include DEFAULT (equivalent to THREE_GPP), AMR_NB, and MPEG_4. ©SoftMoore Consulting

Recording Audio Files (continued) Set output file name using MediaRecorder.setOutputFile(). Set the audio encoder using MediaRecorder.setAudioEncoder(). e.g., to MediaRecorder.AudioEncoder.AMR_NB Call MediaRecorder.prepare() on the MediaRecorder instance. To start audio capture, call MediaRecorder.start(). To stop audio capture, call MediaRecorder.stop(). Call MediaRecorder.release() when recording has been completed to free the resource immediately. ©SoftMoore Consulting

State Diagram for MediaRecorder ©SoftMoore Consulting

Example: Recording an Audio File private MediaRecorder recorder = null; ... // in onCreate() fileName = Environment.getExternalStorageDirectory().getAbsolutePath(); fileName += "/audiorecord.3gp"; private void stopRecording() { recorder.stop(); recorder.release(); recorder = null; } (continued on next slide) ©SoftMoore Consulting

Example: Recording an Audio File (continued) private void startRecording() { recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setOutputFile(fileName); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); try recorder.prepare(); } catch (IOException e) Log.e(LOG_TAG, "prepare() failed"); recorder.start(); ©SoftMoore Consulting

Example: Recording an Audio File (continued) ©SoftMoore Consulting

Example: Playing a Video File Copy video file to the res/raw directory or to external storage on the device. If copied to external storage, add permission to AndroidManifest.xml. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> Create VideoView in layout file. <VideoView android:id="@+id/video" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" /> ©SoftMoore Consulting

Example: Playing a Video File (using res/raw directory) // in onCreate() method VideoView videoView = (VideoView) findViewById(R.id.video); videoView.setMediaController(new MediaController(this)); Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.winter_luck); videoView.setVideoURI(uri); videoView.start(); ©SoftMoore Consulting

Example: Playing a Video File (using external storage) // in constructor fileName = Environment.getExternalStorageDirectory().getAbsolutePath(); fileName += "/winter_luck.mp4"; // in onCreate() method VideoView videoView = (VideoView) findViewById(R.id.video); videoView.setVideoPath(fileName); videoView.setMediaController(new MediaController(this)); videoView.start(); ©SoftMoore Consulting

Example: Playing a Video File (continued) ©SoftMoore Consulting

Relevant Links Media Playback Android Supported Media Formats http://developer.android.com/guide/topics/media/mediaplayer.html Android Supported Media Formats http://developer.android.com/guide/appendix/media-formats.html Audio Capture http://developer.android.com/guide/topics/media/audio-capture.html ©SoftMoore Consulting