Java Code Examples for android.media.AudioManager#GET_DEVICES_OUTPUTS

The following examples show how to use android.media.AudioManager#GET_DEVICES_OUTPUTS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioDeviceListEntry.java    From vinyl-cast with MIT License 6 votes vote down vote up
@TargetApi(23)
static List<AudioDeviceListEntry> createFilteredListFrom(AudioDeviceInfo[] devices, int directionType, Set<Integer> filteredTypes){

    List<AudioDeviceListEntry> listEntries = new Vector<>();
    for (AudioDeviceInfo info : devices) {
        if (directionType == AudioManager.GET_DEVICES_ALL ||
                (directionType == AudioManager.GET_DEVICES_OUTPUTS && info.isSink()) ||
                (directionType == AudioManager.GET_DEVICES_INPUTS && info.isSource())) {
            if (filteredTypes.contains(info.getType())) {
                continue;
            }
            listEntries.add(new AudioDeviceListEntry(info.getId(), info.getType(),
                    info.getProductName() + ": " + AudioDeviceInfoConverter.typeToString(info.getType())));
        }
    }
    return listEntries;
}
 
Example 2
Source File: AudioDevicePreference.java    From vinyl-cast with MIT License 5 votes vote down vote up
@TargetApi(23)
public void setDirectionType(int directionType){
    this.mDirectionType = directionType;

    if (directionType == AudioManager.GET_DEVICES_OUTPUTS) {
        // Add an entry for NONE to the list
        mDeviceAdapter.insert(new AudioDeviceListEntry(AudioRecordStreamProvider.AUDIO_DEVICE_ID_NONE, AudioDeviceInfo.TYPE_UNKNOWN,
                mContext.getString(R.string.audio_device_none)), 0);
    }

    setupAudioDeviceCallback();
}
 
Example 3
Source File: AudioDeviceSpinner.java    From vinyl-cast with MIT License 5 votes vote down vote up
@TargetApi(23)
public void setDirectionType(int directionType){
    this.mDirectionType = directionType;

    if (directionType == AudioManager.GET_DEVICES_OUTPUTS) {
        // Add a default entry to the list and select it
        mDeviceAdapter.insert(new AudioDeviceListEntry(AudioRecordStreamProvider.AUDIO_DEVICE_ID_NONE, AudioDeviceInfo.TYPE_UNKNOWN,
                mContext.getString(R.string.audio_device_none)), 0);
        setSelection(0);
    }

    setupAudioDeviceCallback();
}
 
Example 4
Source File: AudioDeviceListEntry.java    From vinyl-cast with MIT License 5 votes vote down vote up
/**
 * Create a list of AudioDeviceListEntry objects from a list of AudioDeviceInfo objects.
 *
 * @param devices A list of {@Link AudioDeviceInfo} objects
 * @param directionType Only audio devices with this direction will be included in the list.
 *                      Valid values are GET_DEVICES_ALL, GET_DEVICES_OUTPUTS and
 *                      GET_DEVICES_INPUTS.
 * @return A list of AudioDeviceListEntry objects
 */
@TargetApi(23)
static List<AudioDeviceListEntry> createListFrom(AudioDeviceInfo[] devices, int directionType){

    List<AudioDeviceListEntry> listEntries = new Vector<>();
    for (AudioDeviceInfo info : devices) {
        if (directionType == AudioManager.GET_DEVICES_ALL ||
                (directionType == AudioManager.GET_DEVICES_OUTPUTS && info.isSink()) ||
                (directionType == AudioManager.GET_DEVICES_INPUTS && info.isSource())) {
            listEntries.add(new AudioDeviceListEntry(info.getId(), info.getType(),
                    info.getProductName() + " " + AudioDeviceInfoConverter.typeToString(info.getType())));
        }
    }
    return listEntries;
}