package solutions.tretter.mindmachine.audio

import android.content.Context
import android.media.AudioDeviceInfo
import android.media.AudioManager

class HeadsetMonitor(context: Context) {
    private val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager

    fun isStereoHeadsetAvailable(): Boolean {
        return audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS).any {
            (it.type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES
                || it.type == AudioDeviceInfo.TYPE_WIRED_HEADSET
                || it.type == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
                || it.type == AudioDeviceInfo.TYPE_BLE_HEADSET)
        }
    }
}
