CIS 136 Building Mobile Apps

Slides:



Advertisements
Similar presentations
Group 8: Dylan Lentini (AE), Mandy Minuti (WSE), Jean Paul Galea (TL)
Advertisements

Chapter 6 Jam! Implementing Audio in Android Apps.
Chapter 6: Jam! Implementing Audio in Android Apps.
The Web Warrior Guide to Web Design Technologies
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Tutorial 11 Working with Operators and Expressions
JavaScript, Third Edition
“But I don't want to be a “programmer!” ActionScript for journalists Presentation by Mindy McAdams Flashjournalism.com.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Phonegap Bridge – Telephony CIS 136 Building Mobile Apps 1.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
ITCS 6010 SALT. Speech Application Language Tags (SALT) Speech interface markup language Extension of HTML and other markup languages Adds speech and.
CS378 - Mobile Computing Intents.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
1 JavaScript in Context. Server-Side Programming.
Using Client-Side Scripts to Enhance Web Applications 1.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Phonegap Bridge – Compass API CIS 136 Building Mobile Apps 1.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Time Management.  Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming images.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
JavaScript, Fourth Edition
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
Phonegap Bridge – Device, Network, Console, Geolocation API’s CIS 136 Building Mobile Apps 1.
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.
IS2802 Introduction to Multimedia Applications for Business Lecture 4: JavaScript, Loops, and Conditional Statements Rob Gleasure
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Tutorial 11 1 JavaScript Operators and Expressions.
1 Recording VoiceXML sessions with SIPREC draft-lum-siprec-vxml-00 July 30, 2013 IETF 87 Author: H. Lum.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
Phonegap Bridge – Device,Network, Vibration,Battery,Console CIS 136 Building Mobile Apps 1.
Basic coding… with TouchDevelop!!
JavaScript, Sixth Edition
Chapter 9: Value-Returning Functions
Test 2 Review Outline.
Chap 3. Audio/Video api.
Not a Language but a series of techniques
Phonegap Bridge – File System and File Transfer
Android Boot Camp for Developers Using Java, 3E
Introduction to JavaScript Events
Mobile Applications (Android Programming)
CIS 136 Building Mobile Apps
Geolocation using Google maps
CIS 136 Building Mobile Apps
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
JavaScript Selection Statement Creating Array
File System and File Transfer
CIS 136 Building Mobile Apps
CIS 136 Building Mobile Apps
Geolocation using Google maps
Phonegap Bridge Configuration file
CIS 136 Building Mobile Apps
Working with Multimedia
Additional Topics in VB.NET
CIS 136 Building Mobile Apps
Device,Network, Vibration, Console, Accelerometer
Device,Network, Vibration, Console, Accelerometer
Geolocation using Google maps
Presentation transcript:

CIS 136 Building Mobile Apps Multi-Media CIS 136 Building Mobile Apps

Multimedia Plug-ins Camera Media Media Capture

Media API provides the ability to record and play back audio files on a device Although it has global scope, it is not available until after the deviceready event completes

Media Object Syntax: Parameters var media = new Media(src, mediaSuccess, [mediaError], [mediaStatus]); Parameters src: A URI containing the audio content. (DOMString) mediaSuccess: (Optional) The callback that executes after a Media object has completed the current play, record, or stop action. (Function) mediaError: (Optional) The callback that executes if an error occurs. (Function) mediaStatus: (Optional) The callback that executes to indicate status changes. (Function)

Media Status parameter The following constants parameters to the mediaStatus callback: •Media.MEDIA_NONE = 0; •Media.MEDIA_STARTING = 1; •Media.MEDIA_RUNNING = 2; •Media.MEDIA_PAUSED = 3; •Media.MEDIA_STOPPED = 4;

Media Object Methods media.getCurrentPosition(): Returns the current position within an audio file •media.getDuration(): Returns the duration of an audio file •media.play(): Start or resume playing an audio file •media.pause(): Pause playback of an audio file •media.release(): Releases the underlying operating system's audio resources •media.seekTo(): Moves the position within the audio file •media.setVolume(): Set the volume for audio playback •media.startRecord(): Start recording an audio file •media.stopRecord(): Stop recording an audio file •media.stop(): Stop playing an audio file

getCurrentPosition() An asynchronous function that returns the current position of the underlying audio file of a Media object Updates the Media object's position property Position property: The position within the audio playback, in seconds. Not automatically updated during play Must call getCurrentPosition() again to get new position Syntax: media.getCurrentPosition(mediaSuccess, [mediaError]);

getDuration() executes synchronously, returning the duration of the audio file in seconds, if known The duration of the media, in seconds. If the duration is unknown, it returns a value of -1 Syntax: media.getDuration();

pause() executes synchronously, and pauses playing an audio file Syntax: media.pause();

play() executes synchronously, and starts or resumes playing an audio file. Syntax: media.play(); Parameters: numberOfLoops: Pass this option to the play method to specify the number of times you want the media file to play myMedia.play({ numberOfLoops: 2 }) playAudioWhenScreenIsLocked: Pass in this option to the play method to specify whether you want to allow playback when the screen is locked. If set to true (the default value), the state of the hardware mute button is ignored myMedia.play({ playAudioWhenScreenIsLocked : false })

release() executes synchronously, releasing the underlying operating system's audio resources important for Android, since there are a finite amount of OpenCore instances for media playback Apps should call the release function for any Media resource that is no longer needed Syntax: Media.release();

seekTo executes asynchronously, updating the current playback position within an audio file referenced by a Media object updates the Media object's position parameter Syntax: Media.seekTo(milliseconds);

setVolume() asynchronous function that sets the volume during audio playback Syntax: media.setVolume(volume); volume: The volume to set for playback. The value must be within the range of 0.0 to 1.0.

startRecord() executes synchronously starts a recording for an audio file Syntax: media.startRecord();

stop() executes synchronously stops playing an audio file Syntax: media.stop();

stopRecord() executes synchronously stops the recording of an audio file Syntax: media.stopRecord();

MediaError Object Created and returned when an error occurs Properties: code: MediaError.MEDIA_ERR_ABORTED MediaError.MEDIA_ERR_NETWORK MediaError.MEDIA_ERR_DECODE MediaError.MEDIA_ERR_NONE_SUPPORTED message: describes details of the error

Example <body> <a href="#" class="btn large" id=“playIt” >Play Audio</a> <a href="#" class="btn large" id=“pauseIt">Pause Playing Audio</a> <a href="#" class="btn large" id=“stopIt">Stop Playing Audio</a> <p id="audio_pos"></p> </body> <script > $(document).on("deviceready", function() { $(“#playIt”).on(“click", function() { playAudio('http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3');" }); $(“#pauseIt”).on(“click", function() { pauseAudio() $(“#stopIt”).on(“click", function() { stopAudio(); });

Timers

Working with a Timer A timer will run your code automatically based on time elements: setInterval() method Executes the same code continually at intervals clearInterval() method Cancels the setInterval() method call

setInterval -continuous var variable = setInterval("code", millisecondsToRepeat); <script> var counter = 100; $(‘#button’).on(“click”,function(){ var begin=setInterval(countDown(),1000); }); function countDown() { navigator.notification.alert(counter + “ bottles of root beer on the wall”); count--; } </script> </head> <body> </body> </html> CD

Example Creates media object function setAudioPosition(position) { var my_media = null; var mediaTimer = null; function playAudio(src) { my_media = new Media(src, onSuccess, onError); my_media.play(); //update play position every second if (mediaTimer == null) { mediaTimer = setInterval(startLoop , 1000); } } function onSuccess() { console.log("playAudio():Audio Success"); } function startLoop() { my_media.getCurrentPosition(onGetOK, onError); } function onGetOK(position) { if (position > -1) { setAudioPosition(position) + " sec"); function setAudioPosition(position) { document.getElementById('audio_pos').innerHTML = position; function onError(error) { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');

Example Only pause if media object was created // Pause audio function pauseAudio() { if (my_media) { my_media.pause(); } // Stop audio function stopAudio() { my_media.stop(); clearInterval(mediaTimer); mediaTimer = null; Only stop if media object was created