0

I developed an iPhone application that works as a custom music player. I managed to get a list of all songs in my iPhone into a UITableView. When I play a song, sound comes out of the iPhone audio speakers instead of a Bluetooth-connected device.

In this case, I connected an iPhone to Google Glass via Bluetooth. When a call is received on the iPhone, I can hear the caller through the Google Glass headset. When I play a song in my app, however, audio does not get redirected to the Glass headset. The audio plays through the iPhone's speakers. What I had intended was for the music to play through the Bluetooth-connected device instead,

Please advise me on the proper way to stream audio from a Bluetooth-connected device instead of the phone's speakers.

The code I wrote that should have done this is as follows:

 AVAudioSession* audioSession = [AVAudioSession sharedInstance];

    [audioSession setDelegate:self];

   [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: nil];

    [audioSession setActive: YES error: nil];



    // set up for bluetooth microphone input

    UInt32 allowBluetoothInput = 1;

    OSStatus stat = AudioSessionSetProperty (

                                             kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,

                                             sizeof (allowBluetoothInput),

                                             &allowBluetoothInput

                                             );

    NSLog(@"status = %x", (int)stat);    // problem if this is not zero



    // check the audio route

    UInt32 size = sizeof(CFStringRef);

    CFStringRef route;

    OSStatus result = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &size, &route);

    NSLog(@"route = %@", route);

    NSLog(@"result = %d", (int)result);

   CFBundleRef mainBundle = CFBundleGetMainBundle();

    CFURLRef        soundFileURLRef;

    SystemSoundID   soundFileObject;

    soundFileURLRef  = CFBundleCopyResourceURL (mainBundle,CFSTR ("bomb"),CFSTR ("wav"),NULL);

    AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject);

    AudioServicesPlaySystemSound (soundFileObject);

Thank you in advance for your help!

Koh
  • 1,570
  • 1
  • 8
  • 6
Pavan Alapati
  • 317
  • 1
  • 5
  • 17

1 Answers1

1

Currently Glass can not be used as a generic bluetooth headset for music as it does not support the A2DP bluetooth profile.

Brandon Wuest
  • 206
  • 1
  • 2