I am using google Audio Playback Capture API in ANDROID API Level 29 and its working fine on Android mobile devices i get easily internal audio from the devices but when i test it on the Android TV Box , Basically this app is TV box app where i have to capture internal audio. My Android TV Box connected with HDMI cable but i didn't receive any sound i am using Attributes : USAGE_MEDIA,USAGE_UNKNOWN and USAGE_GAME
they are all working fine in mobile app but not when i run on Android Box. I have done everything from my side now i just need help regarding getting audio from HDMI.
Thanks
val config = AudioPlaybackCaptureConfiguration.Builder(AudioCaptureService.mediaProjection!!)
.addMatchingUsage(AudioAttributes.USAGE_MEDIA)
.addMatchingUsage(AudioAttributes.USAGE_UNKNOWN)
.addMatchingUsage(AudioAttributes.USAGE_GAME)
.build()
val audioFormat = AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(buffer.sampleRate)
.setChannelMask(AudioFormat.CHANNEL_IN_MONO)
.build()
val record = AudioRecord.Builder()
.setAudioFormat(audioFormat)
.setAudioPlaybackCaptureConfig(config)
.setBufferSizeInBytes(buffer.size)
.build()
Related
I have an issue related to the headset mic in my android app.
This headset is working absolutely fine with all other apps on this device, but I can’t get audio from it my app. Also this app works fine with headsets on other devices.
Can’t reproduce with other headsets and devices. Same time other wireless headset works fine with my app
Android 12
Device Samsung A12
SDK 31
I use code below
val playbackAttributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
.build()
val audioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT)
.setAudioAttributes(playbackAttributes)
.setAcceptsDelayedFocusGain(true)
.setOnAudioFocusChangeListener { }
.build()
audioManager.requestAudioFocus(audioFocusRequest)
val wired = audioManager.availableCommunicationDevices.firstOrNull { it.type == TYPE_WIRED_HEADSET }
audioManager.mode = AudioManager.MODE_IN_COMMUNICATION
audioManager.setCommunicationDevice(currentDevice)
I'm developing an App using BLE and I need to be able to connect to Android and iOS devices.
I have 3 Samsung Devices, 3 iPhones and one Huawei with Android for testing purposes.
I have an issue with the Huawei device..when scanning for advertisements, Huawei finds all Android devices but no iOS ones. But if I turn bluetooth off and on again, it will find the iOS devices this time if I scan. But only the first time, it won't find them again afterwards until I turn bluetooth off/on again.
Again..only the Huawei is having these issues..what can be the cause?
I scan/advertise like this:
val settings = AdvertiseSettings.Builder()
.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
.setConnectable(true)
.build()
val pUuid = ParcelUuid(UUID.fromString(BluetoothStringsValues.SERVICE_UUID))
val data = AdvertiseData.Builder()
.setIncludeDeviceName(false)
.addServiceUuid(pUuid)
.addServiceData(pUuid, stringToAdvertise.toByteArray(Charset.forName("UTF-8")))
.build()
advertiser.startAdvertising(settings, data, advertisingCallback)
val filter = ScanFilter.Builder()
.setServiceUuid(ParcelUuid(UUID.fromString(SERVICE_UUID)))
.build()
val settings = ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_BALANCED)
.build()
bluetoothLeScanner.startScan(listOf(filter), settings, bleScanCallback)
thanks for the help!
I am getting the following errors when I run my app on Android 9.0. It is not playing the mp3 audio on 9.0 but working good on lower versions.
W/AudioTrack( 5492): Use of stream types is deprecated for operations other than volume control
W/AudioTrack( 5492): See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use case
W/MediaPlayer( 5492): Couldn't open http://myDomain/Intro_1543483066.mp3: java.io.FileNotFoundException: No content provider: http://myDomain/Intro_1543483066.mp3
It's maybe when you request AudioFocus : can you share us the code you use ?
Here is a working sample on how to do it on Android > O :
var audioAttributes = new AudioAttributes.Builder()
.SetLegacyStreamType(Stream.Music).Build();
new AudioFocusRequestClass.Builder(AudioFocus.Gain)
.SetAudioAttributes(audioAttributes)
.SetOnAudioFocusChangeListener(this)
.Build();
I am using Google Mobile Vision API in my Android Application to scan QR codes. The scanning is absolutely fine.
In some phones, the focus is not proper. In Galaxy S4, I have to move the phone back and forth to scan.
The below line is in build.gradle.
compile 'com.google.android.gms:play-services-vision:8.4.0'
This is how I create the CameraSource.
cameraSource = new CameraSource.Builder(this, barcodeDetector).setAutoFocusEnabled(true).build();
Though the auto focus is set to true, the QR code is not focused.
Try using Flag FOCUS_MODE_CONTINUOUS_PICTURE in function setFocusMode
cameraSource = new CameraSource.Builder(this, barcodeDetector)
.setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null)
.setAutoFocusEnabled(true).build();
I'm working on an app to stream audio from shoutcast. The streaming goes well on my computer and when debugging it with an Android-configuration.
But when I deploy it to an APK-file and run it on a Samsung Galaxy S, the streaming doesn't work.
My code for streaming the audio:
var urlRequest:URLRequest = new URLRequest("http://.../;");
var soundContext:SoundLoaderContext = new SoundLoaderContext(2000, true);
soundChannel = new SoundChannel();
sound = new Sound(urlRequest, soundContext);
soundChannel = sound.play();
I've also tried an addEventListener(Event.COMPLETE), it seems my app doesn't get there when running on a Samsung Galaxy.
Pls check internet enabled descripted files.
http://help.adobe.com/en_US/air/build/WSfffb011ac560372f-5d0f4f25128cc9cd0cb-7ffc.html
Reffer Also
http://cookbooks.adobe.com/post_Playing_mp3_files_on_Flex_Mobile-19106.html