App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

Similar documents
App Development for Smart Devices. Lec #12: Audio and Video

<uses-permission android:name="android.permission.internet"/>

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Intents. Your first app assignment

Operator s Manual. minibht Audiometry Android App. Team 2. Samir Dahmani, Nihit Mody, Joseph Wolanski. Client: Dr. Oliver

Interface ใน View class ประกอบด วย

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Vienos veiklos būsena. Theory

App Development for Smart Devices. Lec #18: Advanced Topics

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Manifest.xml. Activity.java

Learn about Android Content Providers and SQLite

8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?

Terms: MediaPlayer, VideoView, MediaController,

Basic GUI elements - exercises

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

Computer Science E-76 Building Mobile Applications

Real-Time Embedded Systems

Meniu. Create a project:

Create Parent Activity and pass its information to Child Activity using Intents.

Arrays of Buttons. Inside Android

Android Beginners Workshop

Starting Another Activity Preferences

Android Workshop: Model View Controller ( MVC):

Practical 1.ListView example

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

Android HelloWorld - Example. Tushar B. Kute,

Simple Currency Converter

App Development for Smart Devices. Lec #9: Advanced Topics

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

App Development for Smart Devices. Lec #8: Android Sensors

Embedded Systems Programming - PA8001

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Database Development In Android Applications

Android Data Storage

else if(rb2.ischecked()) {

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

Android Programs Day 5

Applications. Marco Ronchetti Università degli Studi di Trento

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

M.A.D Assignment # 1

android-espresso #androidespresso

Android. Soft Keyboard Graphics and Media

Android Services. Victor Matos Cleveland State University. Services

GATAV 5. Animations Using a Game Loop

App Development for Android. Prabhaker Matet

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Topics of Discussion

package import import import import import import import public class extends public void super new this class extends public super public void new

Saving application preferences

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Xin Pan. CSCI Fall

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

A Crash Course to Android Mobile Platform

Embedded Systems Programming - PA8001

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

Android Development Tutorial

Designing Apps Using The WebView Control

Android Using Menus. Victor Matos Cleveland State University

Mul$media Techniques in Android. Some of the informa$on in this sec$on is adapted from WiseAndroid.com

Notification mechanism

Getting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Mobile Computing Practice # 2c Android Applications - Interface

Security model. Marco Ronchetti Università degli Studi di Trento

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

public AnimLayer(Context context, AttributeSet attrs, int defstyle) { super(context, attrs, defstyle); initlayer(); }

EMBEDDED SYSTEMS PROGRAMMING Application Basics

UNDERSTANDING ACTIVITIES

Native Android Development Practices

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Android Development Tutorial. Yi Huang

Android & iphone. Amir Eibagi. Localization

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

ANDROID USER INTERFACE

Tłumaczenie i adaptacja materiałów: dr Tomasz Xięski. Na podstawie prezentacji udostępnionych przez Victor Matos, Cleveland State University.

Android - JSON Parser Tutorial

Android Application Model I

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

LECTURE NOTES OF APPLICATION ACTIVITIES

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"

Lecture 14. Android Application Development

Interaction with Android

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

Mobile Image Processing

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

A Quick Intro to Coding Applications for Android Beginners, stop searching Google and start here.

Dynamically Create Admob Banner and Interstitial Ads

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

LifeStreet Media Android Publisher SDK Integration Guide

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Transcription:

App Development for Smart Devices CS 495/595 - Fall 2013 Lec #7: Audio, Video & Telephony Try It Out Tamer Nadeem Dept. of Computer Science

Trt It Out Example - SoundPool Example - VideoView Page 2 Fall 2013 CS 495/595 - App Development for Smart Devices

SoundPool Android provides two API's for playing sounds: SoundPool and MediaPlayer. SoundPool can be used for small audio clips. It can repeat sounds and play several sounds simultaneously. The sound files played with SoundPool should not exceed 1 MB. SoundPool does load the file asynchronously. In recent Android SDK, it is possible to check if the loading is complete via OnLoadCompleteListener. Mediaplayer is better suited for longer music and movies. Page 3 Fall 2013 CS 495/595 - App Development for Smart Devices

Example of SoundPool Create an application that will start playing a sound once the finger touches the display. Create an Android project cs.edu.odu.cs495.soundpool" with the Activity "PlaySound Get a free sound effect from http://hamsterrepublic.com/ohrrpgce/free_sound_effects.html, put it into your "res/raw" folder under the name "sound1.ogg". main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="click on the screen to start playing" android:id="@+id/textview1" android:layout_width="fill_parent" android:layout_height="fill_parent"> </TextView> </LinearLayout> Page 4 Fall 2013 CS 495/595 - App Development for Smart Devices

Example of SoundPool package edu.odu.cs.cs495.soundpool; import android.app.activity; import android.media.audiomanager; import android.media.soundpool; import android.media.soundpool.onloadcompletelistener; import android.os.bundle; import android.util.log; import android.view.motionevent; import android.view.view; import android.view.view.ontouchlistener; public class PlaySound extends Activity implements OnTouchListener { private SoundPool soundpool; private int soundid; boolean loaded = false; Page 5 Fall 2013 CS 495/595 - App Development for Smart Devices

Example of SoundPool /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); View view = findviewbyid(r.id.textview1); view.setontouchlistener(this); // Set the hardware buttons to control the music this.setvolumecontrolstream(audiomanager.stream_music); // Load the sound soundpool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); soundpool.setonloadcompletelistener(new OnLoadCompleteListener() { @Override public void onloadcomplete(soundpool soundpool, int sampleid, int status) { loaded = true; ); soundid = soundpool.load(this, R.raw.sound1, 1); Page 6 Fall 2013 CS 495/595 - App Development for Smart Devices

Example of SoundPool @Override public boolean ontouch(view v, MotionEvent event) { if (event.getaction() == MotionEvent.ACTION_DOWN) { // Getting the user sound settings AudioManager audiomanager = (AudioManager) getsystemservice(audio_service); float actualvolume = (float) audiomanager. getstreamvolume(audiomanager.stream_music); float maxvolume = (float) audiomanager. getstreammaxvolume(audiomanager.stream_music); float volume = actualvolume / maxvolume; // Is the sound loaded already? if (loaded) { soundpool.play(soundid, volume, volume, 1, 0, 1f); Log.e("Test", "Played sound"); return false; Page 7 Fall 2013 CS 495/595 - App Development for Smart Devices

Example of VideoView A simple example using VideoView to play 3gp from YouTube main.xml <?xml version="1.0" encoding="utf- 8"?> <LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <VideoView android:id="@+id/myvideoview" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout> Page 8 Fall 2013 CS 495/595 - App Development for Smart Devices

Example of VideoView package edu.odu.cs.cs495.myvideoview; import android.app.activity; import android.net.uri; import android.os.bundle; import android.widget.mediacontroller; import android.widget.videoview; public class MyVideoView extends Activity { String SrcPath = "rtsp://<replace WITH PATH TO YouTube video (3gp)>"; /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); VideoView myvideoview = (VideoView)findViewById(R.id.myvideoview); myvideoview.setvideouri(uri.parse(srcpath)); myvideoview.setmediacontroller(new MediaController(this)); myvideoview.requestfocus(); myvideoview.start(); Page 9 Fall 2013 CS 495/595 - App Development for Smart Devices