Method StartMusicModeAsync
- Namespace
- Yeelight
- Assembly
- YeelightClient.dll
StartMusicModeAsync(IPAddress?, int, CancellationToken)
Puts the device in music mode: the device makes a connection to this computer, and takes the commands that are sent over it without a limit on their number (and without answering them), which is what it takes to follow music or a screen.
public Task<YeelightMusicSession> StartMusicModeAsync(IPAddress? localAddress = null, int port = 0, CancellationToken cancellationToken = default)
Parameters
localAddressIPAddressThe address of this computer that the device connects to: it has to be reachable from the device. When
nullit is the address that this computer uses to talk to the device, which is the right one on every network.portintThe TCP port to listen on, or
0for a free one.cancellationTokenCancellationTokenTo stop waiting.
Returns
- Task<YeelightMusicSession>
The session, to send commands to the device over.
Remarks
This starts a TCP server on this computer, tells the device where it is, and waits for the device to connect to it (the firewall of this computer has to let it through: a connection from the device to the port that it is told). Only a connection that comes from the address of the device is accepted. Dispose the session to leave music mode; the session also ends when the device closes the connection.
Exceptions
- NotSupportedException
The device does not list
set_music.- ArgumentOutOfRangeException
portis not a port.- YeelightException
The command did not succeed, or the device did not connect.
- OperationCanceledException
The wait was cancelled.