Hi,
I tried to implement the libVLCsharp's chromecast sample ( https://code.videolan.org/mfkl/libvlcsharp-samples/tree/master/Chromecast/Chromecast )
My code is in a windows form (stream on chromecast when I click on the "Button_DIFFUSER" button)
The error is https://imgur.com/mVb6wtN but the dll files are here...
Code: Select all
public partial class Form_MAIN : Form {
readonly HashSet<RendererItem> _rendererItems = new HashSet<RendererItem>();
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
RendererDiscoverer _rendererDiscoverer;
private async void Button_DIFFUSER_ClickAsync(object sender, EventArgs e) {
try {
DiscoverChromecasts();
await Task.Delay(2000);
StartCasting();
}
catch(Exception err) {
MessageBox.Show("erreur : "+err);
}
}
private void StartCasting() {
if(!_rendererItems.Any()) {
MessageBox.Show("No renderer items found. Abort casting...");
return;
}
var media = new Media(_libVLC, "axrtsp://192.168.1.221/axis-media/media.amp", FromType.FromLocation);
_mediaPlayer = new MediaPlayer(_libVLC);
_mediaPlayer.SetRenderer(_rendererItems.First());
_mediaPlayer.Play(media);
}
bool DiscoverChromecasts() {
Core.Initialize();
_libVLC = new LibVLC();
RendererDescription renderer;
renderer = _libVLC.RendererList.FirstOrDefault(r => r.Name.Equals("microdns_renderer"));
_rendererDiscoverer = new RendererDiscoverer(_libVLC, renderer.Name);
_rendererDiscoverer.ItemAdded += RendererDiscoverer_ItemAdded;
return _rendererDiscoverer.Start();
}
void RendererDiscoverer_ItemAdded(object sender, RendererDiscovererItemAddedEventArgs e) {
MessageBox.Show($"New item discovered: {e.RendererItem.Name} of type {e.RendererItem.Type}");
if(e.RendererItem.CanRenderVideo) MessageBox.Show("Can render video");
if(e.RendererItem.CanRenderAudio) MessageBox.Show("Can render audio");
_rendererItems.Add(e.RendererItem);
}
}