How to change from Wi-Fi to 3G while iPhone is receiving an audio stream? - iphone

My iPhone application plays a wma audio stream over the mms:// protocol.
When the Wi-Fi connection drops it won't switch to 3G to continue streaming. I have enough buffer to play for another 15 seconds (I tried to increase the buffer size, but it will stop anyway).
What sort of mechanism can I implement so the playing won't stop and the iPhone changes from Wi-fi to 3G?
In other posts I saw that it should do it automatically, but in my case it doesn't, because its wma over mms protocol.
Thanks!

I may be talking out my butt, however, you could try detecting the Error from the connection when it fails. and restart the stream from your buffered location so you can resume the download. If the internet is down the iPhone should reconnect it to accommodate your new request for the mms feed.

Related

Sending audio in real time from iphone to server?

Is it possible to send audio from iphone to server in real time? I am using AQRecorder which records the data and saves it on a file.I was wondering if there was a way of sending the recorded audio to server in real time.I want to send the audio while it is being recorded.Is it possible? Can we redirect the recorded stream to the server instead of a file?
NOTE:I am using the speak here code from apple https://developer.apple.com/library/ios/samplecode/speakhere/Listings/Classes_AQRecorder_mm.html
Nate is right. A lot of legitimate apps do that. So, you don't even need to have a jailbroken device.
Take a look at this question: Live streaming audio from iPhone
You may be interested to look into open source SIP clients for iOS:
https://code.google.com/p/siphon/
http://www.pjsip.org
http://www.linphone.org/eng/linphone/news/linphone-for-iphone.html

Synchronized Audio Streaming over Bluetooth

I am working on an iPhone app that needs to stream audio file to multiple devices (iPhone) connected via Bluetooth and play it in the Synchronized way, that is, all the devices starts playing the audio file simultaneously.
I am able to make a connection and stream the audio packet and even play the audio file, but the only issue that I am facing is the Latency. All the devices starts playing the audio file at different time, I want all of them to play the same audio packet together. Is there any way I can make them play audio file synchronously?
I remember glancing over audio broadcast option in the bluetooth spec. Not sure whether iphone supports it..

iPhone HE-AAC Streaming over Mobile Network (3G)

Developed an internet radio streamer using jPlayer which utilizes the html5 audio tags with jQuery and has a flash fall back for unsupported browsers. Upon testing the player on the iPhone (iOS 5.0.1), we ran into a very peculiar issue.
When the iPhone is connected to WiFi, it streams perfectly using the HE-AAC V2 stream # 64kbps 44.1kHz (the preferred codec for apple products). However, when the iPhone is connected to the 3G mobile network, it "stutters" or stops streaming for 1-2 secs every 1-2 minutes (does not stop streaming completely). The troubling thing is when the iPhone is forced to use a separate MP3 stream at the same bit rate, it does not have this issue and works very well on 3G.
UPDATE 5
We recently acquired a 3G/4G Sprint mobile hotspot device and tested this issue with the device. When the iPhone is connected to the mobile hotspot, it shows as being connected to a wifi device and the issue does not render even tho the actual connection is via 3G/4G. This might point back to the issue being with the iPhone not handling HE-AAC via HTTP Live Streaming and when directly connected to the mobile network.
UPDATE 4
Updated the iPhone to iOS 5.1 yet the issue persists.
UPDATE 3
Read here on SO various issues of script not rendering correctly when connected to mobile networks. The finger seems to point to the mobile network carriers that may be inserting Proxy to serve webpages, e.g. for downsizing images. Also it might inject some JavaScript pages. The test page can be found HERE Note: this page is using HE-AAC so it will only work on iPhone...
UPDATE
According to Apple's HTTP Live Streaming doc for iOS devices, that "Audio-only content can be either MPEG-2 transport or MPEG elementary audio streams, either in AAC format with ADTS headers or in MP3 format." Our music server is using OddcastV3 encoder to send out three streams (MP3, HE-AAC V2, and Oggvorbis) to the icecastV2 server. Not sure if the encoder is inserting ADTS headers for the HE-AAC V2 stream. Is there a way to check for this?
Comming from a radio planning point of view - here are my two cents:
What you are describing sounds like bandwidth shaping - which is both a common and often neccesary design of radio networks (like 3G networks). In most 3G operators I worked at you would typically optimize your network to give high-speed burst (think downloading an image, sending one email or fetching one HTML page) - over "long-running" high bandwidth services.
This is due to the simple fact that this is what most users want/need.
This shaping can on a typical 3GPP (GSM 3G) network result in that you will first get a RAB (radio access bearer) supporting 384kbit and is then downgraded as long as your your device accepts it.
This means that typicall you will get switched from 384 -> 256 -> 128, then 64kbit where maybe your device starts recieving data to slowly, then the network upgrades it and again downgrade it after a while.
So why is not then the MP3 file stuttering? my guess is that the total kbit rate might differ - so you are fine in the 64kbit RAB. This is a common phenomena.
We have managed to get the exact same thing working. 64kbit AAC-v2 on mobile devices. We are streaming files and not a steady stream, I think Magnus is right when he explains how the network prioritized traffic to bursts, in our case that means we have large parts of the file right away and the player can continue to play until he next burst comes in. In your case that means the stream pauses until the next burst comes.
Either if you can switch to larger chunks in your streaming (larger buffer) or stream whole files instead?
We had a very strange phenomenon with iOS, we had to rename all files from .m4a to .aac to be able to get them streaming on iOS. If we didn't rename them iOS wouldnt play them.
Good luck.

AVPlayer Streaming - Play stream at certain time

Because audio streaming with queues/etc (using Apple's SpeakHere project as an example) is far too complicated for my brain to comprehend, I was thinking about playing streaming music a different way. I have a device that is acting as a "radio station", in that other devices connect to that device via wi-fi and "listen in". So i've implemented cocoaHTTPserver, and what I do is take an MPMediaItem from the iTunes library and put it into the public web folder. I then pass the song URL to the other nearby devices using GameKit. This works great, all of my devices can successfully play the song at the URL of the broadcasting device. My problem is that the stream always starts at the beginning. So if the "radio host device" is 30 seconds in on a song, and then someone connects, the new connection starts the song at the beginning.
So my question is, if I continually pass the current playback time from the host device, to the other devices, if a new device connects to the "stream", is there a way for me on an audio stream using AVPlayer, to set the current plackback time?
So the song 20 seconds in, a new device connects, we tell the new device to start the stream at 20 seconds in. Is that possible?
So i've got this solution working excepting my little problem, and you probably think i'm crazy for doing it this way, but its easier to do it this way than figure out the low level APIs that Apple has for streaming.
I used Matt Galagher's AudioStreamer to play a Mp3 stream. Check this link:
http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html
The article begins with:
This week, I present a sample application that streams and plays an
audio file from a URL on the iPhone or Mac
so it may be helpful.
This post deals with starting playback at any point in the file (startWithOffsetInSecs):
http://www.saygoodnight.com/2009/08/streaming-audio-to-the-iphone-starting-at-an-offset/

Which iPhone API should I be using for streaming audio?

I'm looking to build a little toy app that is very similar to a voip application. One person would hold one iphone and talk to the other iphone. I don't want to use gamekit because it forces a p2p connection and does not work over 3g. I'm worrying about the server side of this later but just wanted to get started with the iPhone side of it. Which API to record audio in real time and which to play it back?
Look to Audio Queue Services for capture and recording. You'd need to come up with a wire protocol to transmit the audio, but the tools to capture and playback or save on either side of the connection can be built using the queue services.