• Stars
    star
    164
  • Rank 228,948 (Top 5 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example project showing audio streaming using HTML5 Audio with PhoneGap on iOS - https://build.phonegap.com/apps/242993

Example project showing audio streaming using HTML5 Audio with PhoneGap on iOS

Why is this here?

I was working on a radio streaming app in PhoneGap and due to a bug in the PhoneGap iOS Media API decided to create a plugin to handle the audio streaming based on the native code I had used in the previous version of the app before discovering PhoneGap.

I got 98% of the way there with my plugin, but in the end it turned out to just be a million times simpler to use html5 audio (new Audio()) to do the streaming in my radio app.

Since shipping that app and effectively abandoning my plugin, I have received a great deal of queries about the plugin and its example project. I have been answering these by pointing people at the web page that got me started using html5 audio nin PhoneGap: http://www.joeldare.com/wiki/play_an_mp3_audio_stream_in_phonegap

However, this is a bit of a cop out... so I decided to re-write my example audio streaming app using the html5 audio instead of my plugin.

Here it is.

Notes

PhoneGap/Cordova

As no PhoneGap API's are used... just pure JavaScript, there is no PhoneGap / Cordova project included. Feel free to just use the contents of the www folder in a new project instead.

Background Audio

If you need background audio, you will need to add the supported modes in your <Projectname>-info.plist (in this case, ExampleHTML5AudioStreaming-Info.plist):

<key>UIBackgroundModes</key>
	<array>
    	<string>audio</string>
	</array>

Also important to note, since iOS6, you must explicitly set the AVAudioSessionCategory.

http://stackoverflow.com/a/12414719/878602

First, import AVFoundation into your AppDelegate.m #import <AVFoundation/AVFoundation.h>

Then add the following to application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL ok;
NSError *setCategoryError = nil;
ok = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];

It is also important to note that background audio does not work in the iOS Simulator... only on an actual device

License

The MIT License

Copyright (c) 2011 Tommy-Carlos Williams (github.com/devgeeks)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

Canvas2ImagePlugin

PhoneGap / Cordova plugin for iOS to save the contents of an HTML canvas to the device's Photo Library
Java
211
star
2

PrivacyScreenPlugin

Cordova / PhoneGap plugin that secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.
Objective-C
102
star
3

grunt-init-cordova

Grunt init template for Apache Cordova cli-generated projects
JavaScript
27
star
4

PhoneListener

PhoneGap / Cordova Android plugin that allows your application to monitor changes in the phone's state (RINGING, OFFHOOK and IDLE) so that you can respond to them appropriately (pause your Media stream, etc).
Java
27
star
5

react-animated-views

A higher order component to make animated page views easier with react-router
JavaScript
20
star
6

VolumeSlider

PhoneGap / Cordova iOS plugin that allows you to add a native volume slider (MPVolumeView) to your app
Objective-C
16
star
7

Canvas2ImageDemo

Demo app for my PhoneGap / Cordova Canvas2ImagePlugin
JavaScript
7
star
8

ExampleAudioStreamer

This is an example of my AudioStreamer plugin in use
JavaScript
6
star
9

tinyvents

A very small and simple lib to attach events to plain JavaScript objects. Inspired by / based on https://github.com/jeromeetienne/microevent.js
JavaScript
5
star
10

echidna.js

Crypton is dead, long live Echidna.js
JavaScript
4
star
11

Notemindr

A Crypton app for creating notes with reminder attached to them
JavaScript
4
star
12

ReadItLaterPlugin

A PhoneGap plugin for iOS for saving a URL to Read It Later (http://readitlaterlist.com)
Objective-C
4
star
13

react-navigation-example

A playground to try and make mobile page navigation better using react
JavaScript
4
star
14

4ZZZ-app

Mobile app for the community radio station 4ZZZfm in Brisbane, QLD Australia
JavaScript
3
star
15

ExampleMobileDevWorkflow

An example of a mobile dev workflow
JavaScript
2
star
16

ChangeAVAudioSessionCategory

Cheap and dirty plugin to change the AVAudioSessionCategory in iOS
Objective-C
2
star
17

jQTouch-theme-for-Android

A very basic beginning of a theme for Android apps using jQTouch
2
star
18

ethernotes

Ethernotes is a zero-knowledge cloud-based notes app powered by Crypton
JavaScript
2
star
19

pixfor-vulnerable

intentionally vulnerable app for PGDay US 2016 Security and Privacy workshop
JavaScript
1
star
20

phonegap-topcoat-react-getting-started

1
star
21

presentation--none-of-the-above

Slides for my talk at the Melbourne Mobile meetup JavaScript UI Faceoff - "None of the above"
JavaScript
1
star