Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Set Next Audio Device as Default (Custom List)

Description
This function selects the next audio device from a list of devices that the user provides. Update the "audioDevices" array in the code with the exact names of the devices you want to cycle through.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
Mar 18, 2015
Date Last Modified
Jan 5, 2016

Scripted Function (Macro) Code

using System;
using System.Drawing;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		//a string to read and write script settings
		const string audioDeviceIndex = "Script_SelectSpecificAudioDevice_Index";
		
		//read the setting in and try to convert it to an integer
		int index;
		if(!Int32.TryParse(BFS.ScriptSettings.ReadValue(audioDeviceIndex), out index))
			index = 0;
		
		//NOTE: add a list of the audio devices you want in this array
		string[] audioDevices = {"Audio Device 1", "Audio Device 2"};
		
		//increment the index and use the mod operator
		//to keep it in the array bounds
		index = ++index % audioDevices.Length;
		
		//load the next audio device from the list
		BFS.Audio.SetDefaultPlaybackSounds(audioDevices[index]);
        BFS.Audio.SetDefaultPlaybackCommunications(audioDevices[index]);
		
		//save the currently selected index
		BFS.ScriptSettings.WriteValue(audioDeviceIndex, "" + index);
	}
}