Android tv box (TX3 mini) run app without connecting display - android

I am trying to use my android tv box (TX3 mini) like a radio. The app I build using react native and expo work and the audio does play when the app is in the background. The audio is coming through AV port and not through HDMI. However when I unplug the HDMI after launching the app, the audio stop working. Is this setting i have to configure in the Android box to keep the audio and the app running when HDMI (display) is unplug or something i have set in my app when coding? I look for setting in the code, but could not find one.
I am using import { Audio } from 'expo-av' library.
Audio settings:
await Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
playsInSilentModeIOS: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
shouldDuckAndroid: true,
staysActiveInBackground: true,
playThroughEarpieceAndroid: true
});
Once the app is running i want to disconnect the display and keep the audio playing on the speaker.
Let me know if you need more details and thanks for any input.
Thanks,
A

Related

Is it possible to play sound effects with Android Auto using app types other than media-apps?

Is it possible to play sound effects with Android Auto using app types other than media-apps (Messaging apps, Navigation, parking & charging apps)?
When I try to play a sound effect using "SoundPool API", it is muted and there is no sound while Android Auto is running.
Is there any good way?
My Source code
https://github.com/LeoAndo/android-auto-automotive-training/blob/main/SoundPoolAutoApp/app/src/main/java/com/leoleo/helloautoapp/sound/MainSoundPlayer.kt
https://github.com/LeoAndo/android-auto-automotive-training/blob/main/SoundPoolAutoApp/app/src/main/java/com/leoleo/helloautoapp/auto/MainScreen.kt
There has been progress.
With the implementation of voice-guidance, it was successful to run the app on the DHU and output sound from the smartphone speaker.(app type: POI)
references:
https://developer.android.com/training/cars/apps/navigation#voice-guidance
https://developer.android.com/guide/topics/media-apps/audio-focus
Was self resolved. By installing the implementation of audio focus, we were able to make sound on the car side.(App Type: POI)
Reference

How to check microphone is already been use or not flutter?

I am building a chat application in which I am sending voice messages. Now when I am calling or any other mobile app is using a microphone then my chat app voice record does not work. How I can check the status of the microphone in a flutter whether it's already in use or not. Thanks
You can try to check flutter audio_session
interceptSession = await AudioSession.instance;
AudioSession.instance.then((audioSession) async {
await audioSession.configure(AudioSessionConfiguration(
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord));
});
await interceptSession.interceptSession.setActive(true);
This plugin informs the operating system of the nature of your audio app (e.g. game, media player, assistant, etc.) and how your app will handle and initiate audio interruptions (e.g. phone call interruptions). It also provides access to all of the capabilities of AVAudioSession on iOS and AudioManager on Android, providing for discoverability and configuration of audio hardware.

How to detect if a headphones / a headset is connected to an Android device in React Native

I am making a calling app where users may or may not use headphones / a headset. On an incoming video call I am using react-native-incall-manager to turn the speaker on / allow speaker phone. The basic InCallManager.start({ media: 'video' }); method works and allows detection of a new audio device being plugged in such as headphones, and if this happens, the headphone and mic plugged in work as expected.
The problem comes in the case that headphones are already plugged in to the device before a call starts, because the InCallManager.setSpeakerphoneOn(true); method is called at that time. InCallManager.start({ media: 'video' }); doesn't account for devices already connected and the headphones do not work, the normal speaker does even though headphones are plugged in.
react-native-incall-manager recommends using DeviceEventEmitter from react-native to detect native events such as changes in connected audio devices, but this module is deprecated.
Here it is recommended to use NativeEventEmitter, but this seems very complex and seems to require the native Java (Android) modules to be written and used in conjunction with it.
How can I detect changes in connected audio devices in Android in React Native?
Here it is recommended to use NativeEventEmitter, but this seems very complex and seems to require the native Java (Android) modules to be written and used in conjunction with it.
You don't need to write a native Java module for this job since NativeEventEmitter can pick up events that were sent through RCTDeviceEventEmitter.
So example from react-native-incall-manager README
import { DeviceEventEmitter } from 'react-native';
DeviceEventEmitter.addListener('Proximity', function (data) {
// --- do something with events
});
can be easily rewritten to this
import { NativeEventEmitter, NativeModules } from 'react-native';
const eventEmitter = new NativeEventEmitter(NativeModules.InCallManager);
eventListener = eventEmitter.addListener('Proximity', event => {
// do something with events
});
Just don't forget to clean up once you no longer need event listeners
eventListener.remove();
If you want to detect changes in connected audio devices you can subscribe to onAudioDeviceChanged event from react-native-incall-manager.
It sends something like this whenever there is a change in connected audio devices or device that will output sound
{"availableAudioDeviceList": "[\"BLUETOOTH\",\"SPEAKER_PHONE\",\"EARPIECE\"]", "selectedAudioDevice": "EARPIECE"}

How to enable android bluetooth a2dp sink and play music on android L

we recently work on a audio box which based on Android, as a audio box must act to a reciver with bluetooth(while a2dp sink profile in bluetooth can do this), but we have do many works over weeks on it , but it still not work, so i'd like to ask somebody who know or had similar expirence on it could help.
our works :
1、packages/apps/Bluetooth/res/values/config.xml
<bool name="profile_supported_a2dp_sink">true</bool>
<bool name="profile_supported_hfpclient">true</bool>
2、external/bluetooth/bluedroid/include/bt_target.h
#define BTA_AV_SINK_INCLUDED TRUE
after these bluetooth seems to worked , i can user a phone link to these box and i can play music with a player through bluetooth , and also i can see the data packages in the box by tcpdump, but there is no sound , we also find some other informations :
Android device as a receiver for A2DP profile
but it seems didn't work.
so anybody could help.
thanks a lot

Recording voice calls in android

I want to make an app that records incoming and outgoing calls. I am using the media recorder to do so and also I am using service/broadcastreceiver to detect phone state change. I have set the audio source as Audiosource.VOICE_CALLS.I am able to record voices at my end but not from the other end. The same happens when the audio source is set as Audiosource.MIC.
Please suggest a solution.
You cannot access the incall audio stream in Android using the public SDK. Call audio is not exposed to apps, and you can only do this if you modify Android at a source level, and then build and install a new image from the customized source to your device.

Categories

Resources