Try this function:
Code:
function MediaExplorer_SetDeviceOutput(channel, mono)
--[[
Meo-Ada Mespotine - 21st of January 2022 - licensed under MIT-license
Sets the output-channel(s) of the Media Explorer
When Media Explorer is opened, playback will be stopped and the Media Explorer will flicker for a short time. This is due limitations in Reaper.
Parameters:
channel: set to the channel number; 1 or higher; -1, Play through first track named "Media Explorer Preview" or first selected track
mono: true, use the mono-channel; false, use stereo-channels
--]]
if channel>-1 then
channel=channel-1
if mono==true then channel=channel+1024 end
end
local A=reaper.GetToggleCommandState(50124)
if A==1 then reaper.Main_OnCommand(50124, 0) end
reaper.BR_Win32_WritePrivateProfileString("reaper_explorer", "outputidx", channel, reaper.get_ini_file())
if A==1 then reaper.Main_OnCommand(50124, 0) end
end
MediaExplorer_SetDeviceOutput(3, false) -- this sets hardwareoutput to channel 3 in stereo
The first parameter is the channel number(1 and higher; -1 for "Play through first track named "Media Explorer Preview" or first selected track") and the second parameter sets, if mono(true) or stereo(false).
However, this will flicker an already opened MediaExplorer quickly and stop any playback. This I cannot circumvent.
But at least, you can set it now programmatically.
Reaper's own API has no such function, afaik.