Пример #1
0
 void DispatchEvent(DZPlayerEvent value, System.Object eventData)
 {
     foreach (Listener l in Listeners)
     {
         l.Notify(value, eventData);
     }
 }
Пример #2
0
    /// <summary>
    /// Is called after a player event is thrown by the SDK. Is used to wait for and manage
    /// asynchronous events.
    /// </summary>
    /// <param name="handle">The player handle. See DZPlayer.</param>
    /// <param name="eventHandle">A pointer to a structure representing the event.</param>
    /// <param name="userData">A pointer to the context given when initializing the DZPlayer.</param>
    public static void PlayerOnEventCallback(IntPtr handle, IntPtr eventHandle, IntPtr userData)
    {
        // We get the object that was given as context from the IntPtr (in that case the ApplicationMainScript itself)
        GCHandle selfHandle       = GCHandle.FromIntPtr(userData);
        ApplicationMainScript app = (ApplicationMainScript)selfHandle.Target;

        DZPlayerEvent playerEvent = DZPlayer.GetEventFromHandle(eventHandle);

        app.IndexInPlaylist = app.Player.GetIndexInQueulist(eventHandle);
        switch (playerEvent)
        {
        case DZPlayerEvent.QUEUELIST_LOADED:
            app.Player.Play();
            break;

        case DZPlayerEvent.QUEUELIST_TRACK_RIGHTS_AFTER_AUDIOADS:
            app.Player.PlayAudioAds();
            break;

        case DZPlayerEvent.RENDER_TRACK_END:
            app.isStopped = true;
            if (app.IndexInPlaylist == -1)
            {
                app.PlayPause();
            }
            break;
        }
        app.DispatchEvent(playerEvent, app.IndexInPlaylist);
    }
Пример #3
0
 public void Notify(DZPlayerEvent playerEvent, System.Object data)
 {
     eventQueue.Enqueue(new Tuple <DZPlayerEvent, System.Object> (playerEvent, data));
 }