public static class CosMediaPlayer {
/// <summary>
/// Set the shown video and optionally the preloading video url.
/// </summary>
/// <remarks>
/// If the video at `videoUrl` is already playing, it will continue playing.
/// You can specify PlaybackOptions to mute the already playing video.
///
/// CosMediaPlayer.SetMediaSources can be called at any time
/// If the current page in the UniWebview is e.g. https://twitch.tv/sodapoppin,
/// then the replays html page is loaded.
/// </remarks>
public static void SetMediaSources(string videoUrl, PlaybackOptions options, string playerKind, string? preloadingVideoUrl = null)
// ...
}
// The UniWebView that CosMediaPlayer uses is set through this method.
public class WebViewMedia {
public static void ReplaceWebViewForMedia(UniWebView? webView)
// ...
}
var myReplay = "https://cosvods.com/cdn/replay/cos-bob/vodid100/hls_multi/master.m3u8";
// large replay player overlay
CosMediaPlayer.SetMediaSources(myReplay, PlaybackOptions.Default, PlayerKind.replays);
// feed player overlay
CosMediaPlayer.SetMediaSources(myReplay, PlaybackOptions.Default, PlayerKind.feedAutoplay);
var replay1 = "https://cosvods.com/cdn/replay/cos-alice/vod111/hls_multi/master.m3u8";
var replay2 = "https://cosvods.com/cdn/replay/cos-bob/vod222/hls_quick/playlist.m3u8";
CosMediaPlayer.SetMediaSources(replay1, PlaybackOptions.Default, PlayerKind.feedAutoplay, replay2);
// *replay1 starts playing as soon as its loaded*
// some time later...
CosMediaPlayer.SetMediaSources(replay2, PlaybackOptions.Default, PlayerKind.feedAutoplay);
// *replay2 starts playing immediately* (it already finished loading)
// OR *replay2 starts playing as soon as its loaded* (it was only partly loaded)