Search code examples
c#wpfvlc

How to embed Twitch/Youtube/Facebook gaming stream?


I'm working on a WPF application and am trying to embed a twitch/youtube/facebook gaming stream. I am relatively new to WPF applications in general.

I've followed the steps outlined at the Twitch Embed API Page, and attempted to insert it into a CEFSharp window using the Twitch embed code. However, as of 2020, twitch now requires a "parent" field to embed their videos, so I just tried plugging the actual twitch page into the CEFsharp element and still it gave me an error.

For Facebook and Youtube, I could get the embedded frames to show up as well, but they both failed to load the video, which leads me to believe there is an issue displaying streaming media through CEFSharp?

Here is the code :

...
xmlns:cef="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
...
                <cef:ChromiumWebBrowser
                    Width="480"
                    Height="270"
                    HorizontalAlignment="Left"
                    Margin="0,20,0,0"
                    Address="https://www.twitch.tv/shroud"
                    />
                <cef:ChromiumWebBrowser
                    Width="480"
                    Height="270"
                    HorizontalAlignment="Left"
                    Margin="0,20,0,0"
                    Address="https://www.youtube.com/embed/Xz5Nw0EY5ng"
                    />
                <cef:ChromiumWebBrowser
                    Width="480"
                    Height="270"
                    HorizontalAlignment="Left"
                    Margin="0,20,0,0"
                    Address="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FNitroLukeDX%2Fvideos%2F710121262901568%2F&amp;show_text=0&amp;width=560" />
                                

And here's the result:

WPF Application Display of streams

Any help would be greatly appreciated!


Solution

  • Ahaa in the end someone pointed me towards the new WebView2 control from ms.

    This plays streaming video :D

    <wv2:WebView2 Name="webView"
           HorizontalAlignment="Left"
           Height="270"
           Width="480"
           Margin="0,20,0,0"
           Source="https://player.twitch.tv/channel=loltyler1"/>