Esempio n. 1
0
    // Open the Media
    public override UAVPError OpenMedia(string URI, UAVPMediaType mediaType)
    {
        Debug.Log("[UAVPlayer_Play] URL[" + URI + "]");
        UAVPError error = UAVPError.UAVP_ERROR_NONE;

        if (CanOutputToTexture(URI))
        {
            error = UAVP_OpenVideo(URI, mediaType);
            if (error == UAVPError.UAVP_ERROR_NONE)
            {
                if (autoplay)
                {
                    _status = UAVPStatus.UAVP_START;
                }
                else
                {
                    _status = UAVPStatus.UAVP_OPEN;
                }
            }
            else
            {
                _status = UAVPStatus.UAVP_NONE;
            }
        }
        else
        {
            error = UAVPError.UAVP_Error_OPENFAILED;

            _status = UAVPStatus.UAVP_NONE;
        }
        return(error);
    }
Esempio n. 2
0
    // Release the Player
    public override void Release()
    {
        Debug.Log("[UAVPlayer_Release]");

        UAVPError error = UAVP_ReleasePlayer();

        if (error == UAVPError.UAVP_ERROR_NONE)
        {
            _status = UAVPStatus.UAVP_RELEASE;
        }
        else
        {
            _status = UAVPStatus.UAVP_RELEASE;
        }
    }
Esempio n. 3
0
    // Start to media playback
    public override void Start()
    {
        Debug.Log("[UAVPlayer_Start]");

        UAVPError error = UAVP_PlayVideo();

        if (error == UAVPError.UAVP_ERROR_NONE)
        {
            _status = UAVPStatus.UAVP_START;
        }
        else
        {
            _status = UAVPStatus.UAVP_NONE;
        }
    }
Esempio n. 4
0
    // Initialize the Media Player
    public override UAVPError InitPlayer(UAVPLogLevel logLevel)
    {
        UAVPError error = UAVP_InitPlayer();

        UAVP_setUAVPTimeListener(new uavplayerTimeDelegate(UAVPTimeListener));

        if (error == UAVPError.UAVP_ERROR_NONE)
        {
            _status = UAVPStatus.UAVP_INIT;
        }
        else
        {
            _status = UAVPStatus.UAVP_NONE;
        }

        return(error);
    }
Esempio n. 5
0
    // Pause the Player
    public override void Pause()
    {
        Debug.Log("[UAVPlayer_Pause]");

        if (videoReady)
        {
            UAVPError error = UAVP_PauseVideo();

            if (error == UAVPError.UAVP_ERROR_NONE)
            {
                _status = UAVPStatus.UAVP_PAUSE;
            }
            else
            {
                _status = UAVPStatus.UAVP_NONE;
            }
        }
    }
Esempio n. 6
0
        // Start is called before the first frame update
        void Start()
        {
            Debug.Log("UAVP Version: " + uavp_version);
            // Initialize the property
            if (seekbar != null)
            {
                EventTrigger eventTrigger = seekbar.gameObject.AddComponent <EventTrigger>();

                // When Click the Slider
                EventTrigger.Entry entry_PointerDown = new EventTrigger.Entry();
                entry_PointerDown.eventID = EventTriggerType.PointerDown;
                entry_PointerDown.callback.AddListener((data) => { OnPointerDown((PointerEventData)data); });
                eventTrigger.triggers.Add(entry_PointerDown);

                // When Touch Up the Slider
                EventTrigger.Entry entry_EndDrag = new EventTrigger.Entry();
                entry_EndDrag.eventID = EventTriggerType.EndDrag;
                entry_EndDrag.callback.AddListener((data) => { OnEndDrag((PointerEventData)data); });
                eventTrigger.triggers.Add(entry_EndDrag);
            }
            if (player != null)
            {
                if (autoPlay)
                {
                    player.setProperty(UAVPProperty.UAVP_AUTOPLAY, 1);
                }
                else
                {
                    player.setProperty(UAVPProperty.UAVP_AUTOPLAY, 0);
                }

                if (loop)
                {
                    player.setProperty(UAVPProperty.UAVP_LOOP, 1);
                }
                else
                {
                    player.setProperty(UAVPProperty.UAVP_LOOP, 0);
                }

                if (mute)
                {
                    player.setProperty(UAVPProperty.UAVP_MUTE, 1);
                }
                else
                {
                    player.setProperty(UAVPProperty.UAVP_MUTE, 0);
                }
            }

            if (seekbar != null)
            {
                seekbar.minValue = 0;
            }

            if (videoMat != null)
            {
                videoMat.mainTexture = null;
            }

            if (player != null)
            {
                // Register the Event
                UAVPlayerSource.onEvent += EventNotify;

                UAVPError error = player.InitPlayer(logLevel);
                if (error == UAVPError.UAVP_ERROR_NONE)
                {
                    if (mediaPlayType == UAVPMediaType.UAVP_Streaming_Media)            // Streaming
                    {
                        Debug.Log("Play Streaming");
                        URI = mediaURI;
                    }
                    else if (mediaPlayType == UAVPMediaType.UAVP_StreamingAsset_Media)  // StreamingAsset
                    {
                        if (Application.platform == RuntimePlatform.OSXEditor)
                        {
                            Debug.Log("Play StreamingAsset Media");
                            if (assetFileURI != null)
                            {
                                URI = UAVPUtility.GetLocalURI(Application.dataPath + "/StreamingAssets/" + assetFileURI);
                            }
                            else
                            {
                                URI = null;
                            }
                        }
                        else if (Application.platform == RuntimePlatform.IPhonePlayer)
                        {
                            URI = assetFileURI;
                        }
                    }
                    else if (mediaPlayType == UAVPMediaType.UAVP_Local_Media)           // Local
                    {
                        if (Application.platform == RuntimePlatform.OSXEditor)
                        {
                            Debug.Log("Play Local Media");
                            if (localURI != null)
                            {
                                URI = UAVPUtility.GetLocalURI(localURI);
                            }
                            else
                            {
                                URI = null;
                            }
                        }
                        else if (Application.platform == RuntimePlatform.IPhonePlayer)
                        {
                            URI = localURI;
                        }
                    }

                    if (URI != null)
                    {
                        Debug.Log("Start to play [" + URI + "]");
                        player.OpenMedia(URI, mediaPlayType);
                    }
                    else
                    {
                        Debug.Log("URI is null");
                    }

                    openEvent.Invoke();
                }
                else
                {
                    player = null;
                }
            }
            else
            {
                Debug.Log("Player is null");
            }
        }