kakone / GoogleCast

Implementation of the Google Cast protocol (.NET Standard 2.0 library)
GNU General Public License v3.0
144 stars 22 forks source link

How to join to already started session to stop/pause MediaChannel? #6

Closed Marcus-L closed 7 years ago

Marcus-L commented 7 years ago

In Program1:

var sender = new Sender();
var receiver = new Receiver()
{
    IPEndPoint = CreateIPEndPoint(...)
};
// Connect to the Chromecast
await sender.ConnectAsync(receiver);
var channel = sender.GetChannel<IMediaChannel>();
await sender.LaunchAsync(channel);
await channel.LoadAsync(new Media{  ContentId = "http://.../media.mp3"});

(starts playing the media.mp3 file)

Then in Program2:

var sender = new Sender();
var receiver = new Receiver()
{
    IPEndPoint = CreateIPEndPoint(...)
};
// Connect to the Chromecast
await sender.ConnectAsync(receiver);
var channel = sender.GetChannel<IMediaChannel>();
await sender.LaunchAsync(channel);
await channel.StopAsync();

Gets an exception about a null MediaSessionId. This is expected since we didn't start the session, but is there a way to stop the already playing stream?

Marcus-L commented 7 years ago

This is resolved with PR #7