主播模式目前正在開發中!
此 Python 套件提供了一個方便的接口,用於與 SteelSeries Sonar 應用程式 API 進行互動。
聲納應用程式允許使用者控制和顯示各種音訊通道的音量。
若要使用此包,請按照下列步驟操作:
使用 pip 安裝套件:
pip install steelseries-sonar-py
在 Python 腳本或應用程式中導入Sonar
類別:
from steelseries_sonar_py import Sonar
Sonar 類別在初始化期間接受兩個可選參數:
streamer_mode
:設定為 True 以使用流光模式(預設為 False)。
app_data_path
:指定 SteelSeries Engine 3 coreProps.json 檔案的自訂路徑
(預設為預設安裝路徑: C:\ProgramData\SteelSeries\SteelSeries Engine 3\coreProps.json
)。
sonar = Sonar ( app_data_path = "C: \ path \ to \ coreProps.json" )
或者
sonar = Sonar ( app_data_path = "C: \ path \ to \ coreProps.json" , streamer_mode = True )
steelseries sonar py Thon API 支援流模式,讓使用者可以管理兩個獨立的滑桿: streaming
和monitoring
。這些滑桿可以對不同的音訊通道進行微調控制。
若要檢查串流模式是否已啟用,請使用:
is_streaming = sonar . is_streamer_mode ()
print ( "Is Streamer Mode:" , is_streaming )
若要啟用或停用串流模式,請使用:
# Enable streamer mode
sonar . set_streamer_mode ( True )
# Disable streamer mode
sonar . set_streamer_mode ( False )
檢索有關所有通道目前音量設定的資訊:
volume_data = sonar . get_volume_data ()
print ( volume_data )
設定特定頻道的音量。 channel
參數應為以下之一:
master
、 game
、 chatRender
、 media
、 aux
、 chatCapture
。 volume
參數應該是 0 到 1 之間的浮點數。
此外,還可提供可選的streamer_slider
參數,其值為「streaming」(預設)或「monitoring」:
channel = "master"
volume = 0.75
streamer_slider = "streaming" # or "monitoring"
result = sonar . set_volume ( channel , volume , streamer_slider = streamer_slider )
print ( result )
切換特定通道的靜音狀態。 channel
參數應為以下之一:
master
、 game
、 chatRender
、 media
、 aux
、 chatCapture
。 muted
參數應該是布林值,指示是否將通道靜音 ( True
) 還是取消靜音 ( False
)。
此外,還可提供可選的streamer_slider
參數,其值為「streaming」(預設)或「monitoring」:
channel = "game"
muted = True
streamer_slider = "monitoring"
result = sonar . mute_channel ( channel , muted , streamer_slider = streamer_slider )
print ( result )
檢索聊天組合資料:
chatmix_data = sonar . get_chat_mix_data ()
print ( chatmix_data )
將 chat-mix 值設定在-1 and 1
之間,以集中來自game
或chatRender
頻道的聲音:
result = sonar . set_chat_mix ( 0.5 )
print ( result )
該包引入了一組在使用過程中可能引發的異常。
建議在程式碼中相應地處理這些異常。
您可以從steelseries_sonar_py.exceptions
匯入它們。以下是潛在例外的清單:
EnginePathNotFoundError
:當未安裝 SteelSeries Engine 3 或不在預設位置時引發。ServerNotAccessibleError
:當無法存取 SteelSeries 伺服器時引發。提供 HTTP 狀態碼。SonarNotEnabledError
:未啟用 SteelSeries Sonar 時引發。ServerNotReadyError
:當 SteelSeries Sonar 未就緒時引發。ServerNotRunningError
:SteelSeries Sonar 未執行時間引發。WebServerAddressNotFoundError
:未找到 Web 伺服器位址時引發。ChannelNotFoundError
:未找到指定頻道時引發。InvalidVolumeError
:提供無效的磁碟區值時引發。InvalidMixVolumeError
:提供無效的混合音量值時引發。SliderNotFoundError
:當提供未知滑桿名稱作為streamer_slider
值時引發。 下面是一個完整的範例,示範了steelseries sonar py thon API 的用法:
from steelseries_sonar_py import Sonar
from steelseries_sonar_py . exceptions import EnginePathNotFoundError
# Initialize Sonar object
try :
sonar = Sonar ( app_data_path = "C: \ path \ to \ coreProps.json" )
except EnginePathNotFoundError :
print ( "Engine not found!" )
quit ()
# Retrieve volume data
volume_data = sonar . get_volume_data ()
print ( "Volume Data:" , volume_data )
# Set volume for the 'master' channel
channel = "master"
volume = 0.8
streamer_slider = "streaming"
result = sonar . set_volume ( channel , volume , streamer_slider = streamer_slider )
print ( f"Set volume for { channel } :" , result )
# Mute the 'game' channel
channel = "game"
muted = True
streamer_slider = "monitoring"
result = sonar . mute_channel ( channel , muted , streamer_slider = streamer_slider )
print ( f"Mute { channel } :" , result )
# Retrieve chat-mix data
chatmix_data = sonar . get_chat_mix_data ()
print ( "Chatmix Data:" , chatmix_data )
# Set chat-mix value
result = sonar . set_chat_mix ( 0.5 )
print ( "Set Chatmix:" , result )
感謝所有使這個包成為可能的貢獻者 - wex 找出了 API,TotalPanther317 用於理解串流媒體模式,cookie 用於聊天混合和串流媒體模式檢測等功能。感謝他們的努力!
本文檔現在反映了steelseries sonar py Thon API 的最新變更和新增。