/// <summary> /// This is where we generate the markup required to make events work. /// TODO: Move the JS code to a script and make a simple call here? /// </summary> /// <param name="eventName">The DOM event name e.g. play, pause etc</param> /// <param name="payloadName">In case someone wants to change it. Don't though.</param> /// <returns>A string containing JS code for the event handler</returns> async Task Implement(VideoEvents eventName) { VideoStateOptions options = default; VideoEventOptions?.TryGetValue(eventName, out options); await JS.InvokeVoidAsync("Blazored.registerCustomEventHandler", videoRef, eventName.ToString().ToLower(), options.GetPayload()); }
public VideoPlayerBase() { Timer ??= new Timer(TimeSpan.FromSeconds(10).TotalMilliseconds); Timer.AutoReset = true; Timer.Elapsed += Timer_Elapsed; VideoStateOptions = new Dictionary <VideoEvents, VideoStateOptions>(); var videoStateOptions = new VideoStateOptions { CurrentTime = true, CurrentSrc = true, Duration = true, Volume = true }; VideoStateOptions[VideoEvents.TimeUpdate] = videoStateOptions; VideoStateOptions[VideoEvents.Play] = videoStateOptions; VideoStateOptions[VideoEvents.Pause] = videoStateOptions; VideoStateOptions[VideoEvents.VolumeChange] = videoStateOptions; }