private static void mk_media_play(IntPtr mk_media_info, IntPtr auth_invoker, IntPtr mk_sock_info) { if (OnMediaPlay == null) { PInvoke.ZLMediaKitMethod.mk_auth_invoker_do(auth_invoker, null); return; } var mediaInfo = new MediaInfo(mk_media_info); var list = new List <Task <MediaSourceWapper> >(); foreach (Func <MediaInfo, MediaSourceWapper> item in OnInternalMediaPlay.GetInvocationList()) { list.Add(Task <MediaSourceWapper> .Run(() => item(mediaInfo))); } Task.WaitAll(list.ToArray()); var mediasourceWapper = list.FirstOrDefault(w => w.Result != null)?.Result; var sockinfo = new SockInfo(mk_sock_info); bool notMedia = mediasourceWapper == null; mediasourceWapper = new MediaSourceWapper { MediaInfo = new MediaInfo(mk_media_info) }; var result = OnMediaPlay.Invoke(mediasourceWapper, sockinfo); if (string.IsNullOrEmpty(result)) { mediasourceWapper._watchClient.Add(new WatchClient(new SockInfo(mk_sock_info))); } PInvoke.ZLMediaKitMethod.mk_auth_invoker_do(auth_invoker, result); }
/// <summary> /// /// </summary> /// <param name="app"></param> /// <param name="payload"></param> private void HandlePayload(IApplicationBuilder app, Payload payload) { _logger.LogInformation($"OnPayLoadReceived: {payload}"); OnPayloadReceived?.Invoke(app, new PayloadEventArgs(payload)); switch (payload.Event) { case EventType.MediaPlay: OnMediaPlay?.Invoke(app, EventArgs.Empty); break; case EventType.MediaPause: OnMediaPause?.Invoke(app, EventArgs.Empty); break; case EventType.MediaResume: OnMediaResume?.Invoke(app, EventArgs.Empty); break; case EventType.MediaStop: OnMediaStop?.Invoke(app, EventArgs.Empty); break; case EventType.MediaScrobble: OnMediaScrobble?.Invoke(app, EventArgs.Empty); break; case EventType.MediaRate: OnMediaRate?.Invoke(app, EventArgs.Empty); break; } }