I iCAB Well-Known Member Licensed User Longtime User Mar 3, 2018 #1 Hi All I have an application that plays audio files. I do have one of these bluetooth/fm units that makes it possible to play music over the car audio system, by converting the bluetooth audio to FM: https://www.amazon.ca/VicTsing-Transmitter-Bluetooth-Flexible-Gooseneck/dp/B0196A4U6O with B4A, the received audio plays over the car system no problem. With B4I MediaPlayer it is not ...while playing music is fine. Below is the code I am using B4X: Dim no As NativeObject = Me no.RunMethod("setAudioSession", Null) mpRef.Initialize( FileFolder, FileName, "mp") mpRef.Looping = False mpRef.Play Any ideas how to make this work? iCAB
Hi All I have an application that plays audio files. I do have one of these bluetooth/fm units that makes it possible to play music over the car audio system, by converting the bluetooth audio to FM: https://www.amazon.ca/VicTsing-Transmitter-Bluetooth-Flexible-Gooseneck/dp/B0196A4U6O with B4A, the received audio plays over the car system no problem. With B4I MediaPlayer it is not ...while playing music is fine. Below is the code I am using B4X: Dim no As NativeObject = Me no.RunMethod("setAudioSession", Null) mpRef.Initialize( FileFolder, FileName, "mp") mpRef.Looping = False mpRef.Play Any ideas how to make this work? iCAB
Erel B4X founder Staff member Licensed User Longtime User Mar 4, 2018 #2 Can you post the inline OBJC code? Upvote 0
I iCAB Well-Known Member Licensed User Longtime User Mar 4, 2018 #3 Hi Erel Thanks for your reply. Here is the code I am using B4X: #If OBJC #import <AVFoundation/AVFoundation.h> - (void) setAudioSession { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error: nil]; } #end if Upvote 0
Hi Erel Thanks for your reply. Here is the code I am using B4X: #If OBJC #import <AVFoundation/AVFoundation.h> - (void) setAudioSession { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error: nil]; } #end if
Erel B4X founder Staff member Licensed User Longtime User Mar 4, 2018 #4 Try to change the option to: AVAudioSessionCategoryOptionAllowBluetooth Upvote 0
I iCAB Well-Known Member Licensed User Longtime User Mar 5, 2018 #5 Hi Erel Thanks for your help. I had to OR(|) the options to have both working (otherwise the speaker won't work ). Here is the new code B4X: #If OBJC #import <AVFoundation/AVFoundation.h> - (void) setAudioSession { //[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error: nil]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker error: nil]; } #end if Thanks again for the exceptional support iCAB Upvote 0
Hi Erel Thanks for your help. I had to OR(|) the options to have both working (otherwise the speaker won't work ). Here is the new code B4X: #If OBJC #import <AVFoundation/AVFoundation.h> - (void) setAudioSession { //[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error: nil]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker error: nil]; } #end if Thanks again for the exceptional support iCAB