Пример #1
0
 public static void CallOnEvent(NexPlayerEvent eventType, int param1, int param2)
 {
     if (OnEventStatic != null)
     {
         OnEventStatic(eventType, param1, param2);
     }
 }
Пример #2
0
 private void CallOnEvent(NexPlayerEvent eventType, int param1, int param2)
 {
     if (OnEvent != null)
     {
         OnEvent(eventType, param1, param2);
     }
 }
Пример #3
0
    void EventNotify(NexPlayerEvent paramEvent, int param1, int param2)
    {
        if (paramEvent != NexPlayerEvent.NEXPLAYER_EVENT_ON_TIME)
        {
            Debug.Log("EventNotify: " + paramEvent + ", param1: " + param1 + ", param2: " + param2);
        }

        switch (paramEvent)
        {
        case NexPlayerEvent.NEXPLAYER_EVENT_TEXTURE_CHANGED:
            // It's important to change the texture of every Unity object that should display the video frame when this callback is called
            if (GetComponent <Renderer>())
            {
                GetComponent <Renderer>().material.mainTexture = player.GetTexture();
            }
            else
            {
                GetComponent <RawImage>().texture = player.GetTexture();
            }

            if (rendererToUpdate != null)
            {
                foreach (Renderer renderer in rendererToUpdate)
                {
                    renderer.material.mainTexture = player.GetTexture();
                }
            }
            break;

        case NexPlayerEvent.NEXPLAYER_EVENT_ON_TIME:
            SetCurrentTime(); break;

        case NexPlayerEvent.NEXPLAYER_EVENT_TRACK_CHANGED:
            SetVideoSize(); break;

        case NexPlayerEvent.NEXPLAYER_EVENT_INIT_COMPLEATE:
        {
            status.text           = "Opened";
            playPauseImage.sprite = playSprite;
        }
        break;

        case NexPlayerEvent.NEXPLAYER_EVENT_PLAYBACK_STARTED:
        {
            SetTotalTime();
            status.text           = "Playing";
            playPauseImage.sprite = pauseSprite;
        }
        break;

        case NexPlayerEvent.NEXPLAYER_EVENT_PLAYBACK_PAUSED:
        {
            status.text           = "Pause";
            playPauseImage.sprite = playSprite;
        }
        break;

        case NexPlayerEvent.NEXPLAYER_EVENT_END_OF_CONTENT:
        {
            status.text           = "Pause";
            playPauseImage.sprite = playSprite;
            ToogleQuit();
        }
        break;

        case NexPlayerEvent.NEXPLAYER_EVENT_BUFFERING_STARTED:
            status.text = "Buffering..."; break;

        case NexPlayerEvent.NEXPLAYER_EVENT_BUFFERING_ENDED:
        {
            NexPlayerStatus statusPlayer = player.GetStatusPlayer();
            if (statusPlayer == NexPlayerStatus.NEXPLAYER_STATUS_PLAYING)
            {
                status.text = "Playing";
            }
            else if (statusPlayer == NexPlayerStatus.NEXPLAYER_STATUS_PAUSED)
            {
                status.text = "Pause";
            }
        }
        break;

        case NexPlayerEvent.NEXPLAYER_EVENT_ERROR:
        {
            status.text = "Error";
            player      = null;
            switch (param1)
            {
            case (int)NexPlayerError.NEXPLAYER_ERROR_GENERAL: Debug.LogError("NEXPLAYER_ERROR_GENERAL"); break;

            case (int)NexPlayerError.NEXPLAYER_ERROR_SRC_NOT_FOUND: Debug.LogError("NEXPLAYER_ERROR_SRC_NOT_FOUND"); break;
            }
        }
        break;

        case NexPlayerEvent.NEXPLAYER_EVENT_CLOSED:
        {
            player = null;

            GoBack();
        }
        break;
        }
    }