public override VideoState GetState()
        {
            MediaPlayerCtrl.MEDIAPLAYER_STATE state = player.GetCurrentState();

            switch (state)
            {
            case MediaPlayerCtrl.MEDIAPLAYER_STATE.READY:
                return(VideoState.Ready);

            case MediaPlayerCtrl.MEDIAPLAYER_STATE.END:
                return(VideoState.End);

            case MediaPlayerCtrl.MEDIAPLAYER_STATE.ERROR:
                return(VideoState.Error);

            case MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY:
                return(VideoState.NotReady);

            case MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED:
                return(VideoState.Paused);

            case MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING:
                return(VideoState.Playing);

            case MediaPlayerCtrl.MEDIAPLAYER_STATE.STOPPED:
                return(VideoState.Stopped);

            default:
                return(VideoState.Error);
            }
        }
Esempio n. 2
0
 public void Pause()
 {
     if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
     {
         this.Call_Pause();
     }
     this.m_CurrentState = MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED;
 }
Esempio n. 3
0
 public void Stop()
 {
     if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
     {
         this.Call_Pause();
     }
     this.m_bStop                = true;
     this.m_CurrentState         = MediaPlayerCtrl.MEDIAPLAYER_STATE.STOPPED;
     this.m_iCurrentSeekPosition = 0;
 }
 public void Load(string strFileName)
 {
     if (this.GetCurrentState() != MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY)
     {
         this.UnLoad();
     }
     this.m_bFirst      = false;
     this.m_bCheckFBO   = false;
     this.m_strFileName = strFileName;
     if (!this.m_bInit)
     {
         return;
     }
     this.m_CurrentState = MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY;
 }
Esempio n. 5
0
    public void TogglePlayPause()
    {
        MediaPlayerCtrl.MEDIAPLAYER_STATE cState = preLoaded[currentVideoIndex].GetCurrentState();

        if (cState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            preLoaded[currentVideoIndex].Pause();
        }

        else if (cState == MediaPlayerCtrl.MEDIAPLAYER_STATE.READY ||
                 cState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED ||
                 cState == MediaPlayerCtrl.MEDIAPLAYER_STATE.STOPPED ||
                 cState == MediaPlayerCtrl.MEDIAPLAYER_STATE.END)
        {
            preLoaded[currentVideoIndex].Play();
        }
    }
Esempio n. 6
0
 public override bool IsLoaded()
 {
     MediaPlayerCtrl.MEDIAPLAYER_STATE state = controls.GetCurrentState();
     return(state != MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY &&
            state != MediaPlayerCtrl.MEDIAPLAYER_STATE.ERROR);
 }
Esempio n. 7
0
 public void UnLoad()
 {
     this.m_bCheckFBO = false;
     this.Call_UnLoad();
     this.m_CurrentState = MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY;
 }
Esempio n. 8
0
 private void Update()
 {
     if (string.IsNullOrEmpty(this.m_strFileName))
     {
         return;
     }
     if (this.checkNewActions)
     {
         this.checkNewActions = false;
         this.CheckThreading();
     }
     if (!this.m_bFirst)
     {
         string str = this.m_strFileName.Trim();
         if (this.m_bSupportRockchip)
         {
             this.Call_SetRockchip(this.m_bSupportRockchip);
             if (str.Contains("://"))
             {
                 this.Call_Load(str, 0);
             }
             else
             {
                 this.StartCoroutine(this.CopyStreamingAssetVideoAndLoad(str));
             }
         }
         else
         {
             this.Call_Load(str, 0);
         }
         this.Call_SetLooping(this.m_bLoop);
         this.m_bFirst = true;
     }
     if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING || this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED)
     {
         if (!this.m_bCheckFBO)
         {
             if (this.Call_GetVideoWidth() <= 0 || this.Call_GetVideoHeight() <= 0)
             {
                 return;
             }
             this.m_iWidth  = this.Call_GetVideoWidth();
             this.m_iHeight = this.Call_GetVideoHeight();
             this.Resize();
             if (Object.op_Inequality((Object)this.m_VideoTexture, (Object)null))
             {
                 if (Object.op_Inequality((Object)this.m_VideoTextureDummy, (Object)null))
                 {
                     Object.Destroy((Object)this.m_VideoTextureDummy);
                     this.m_VideoTextureDummy = (Texture2D)null;
                 }
                 this.m_VideoTextureDummy = this.m_VideoTexture;
                 this.m_VideoTexture      = (Texture2D)null;
             }
             this.m_VideoTexture = !this.m_bSupportRockchip ? new Texture2D(this.Call_GetVideoWidth(), this.Call_GetVideoHeight(), (TextureFormat)4, false) : new Texture2D(this.Call_GetVideoWidth(), this.Call_GetVideoHeight(), (TextureFormat)7, false);
             ((Texture)this.m_VideoTexture).set_filterMode((FilterMode)1);
             ((Texture)this.m_VideoTexture).set_wrapMode((TextureWrapMode)1);
             this.m_texPtr = ((Texture)this.m_VideoTexture).GetNativeTexturePtr();
             this.Call_SetUnityTexture((int)this.m_texPtr);
             this.Call_SetWindowSize();
             this.m_bCheckFBO = true;
             if (this.OnResize != null)
             {
                 this.OnResize();
             }
         }
         else if (this.Call_GetVideoWidth() != this.m_iWidth || this.Call_GetVideoHeight() != this.m_iHeight)
         {
             this.m_iWidth  = this.Call_GetVideoWidth();
             this.m_iHeight = this.Call_GetVideoHeight();
             if (this.OnResize != null)
             {
                 this.OnResize();
             }
             this.ResizeTexture();
         }
         this.Call_UpdateVideoTexture();
         this.m_iCurrentSeekPosition = this.Call_GetSeekPosition();
     }
     if (this.m_CurrentState != this.Call_GetStatus())
     {
         this.m_CurrentState = this.Call_GetStatus();
         if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.READY)
         {
             if (this.OnReady != null)
             {
                 this.OnReady();
             }
             if (this.m_bAutoPlay)
             {
                 this.Call_Play(0);
             }
             if (this.m_bReadyPlay)
             {
                 this.Call_Play(0);
                 this.m_bReadyPlay = false;
             }
             this.SetVolume(this.m_fVolume);
         }
         else if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.END)
         {
             if (this.OnEnd != null)
             {
                 this.OnEnd();
             }
             if (this.m_bLoop)
             {
                 this.Call_Play(0);
             }
         }
         else if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.ERROR)
         {
             this.OnError((MediaPlayerCtrl.MEDIAPLAYER_ERROR) this.Call_GetError(), (MediaPlayerCtrl.MEDIAPLAYER_ERROR) this.Call_GetErrorExtra());
         }
     }
     GL.InvalidateState();
 }
 private void Update()
 {
     if (string.IsNullOrEmpty(this.m_strFileName))
     {
         return;
     }
     if (!this.m_bFirst)
     {
         string text = this.m_strFileName.Trim();
         if (this.m_bSupportRockchip)
         {
             this.Call_SetRockchip(this.m_bSupportRockchip);
             if (text.Contains("://"))
             {
                 this.Call_Load(text, 0);
             }
             else
             {
                 base.StartCoroutine(this.CopyStreamingAssetVideoAndLoad(text));
             }
         }
         else
         {
             this.Call_Load(text, 0);
         }
         this.Call_SetLooping(this.m_bLoop);
         this.m_bFirst = true;
     }
     if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING || this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED)
     {
         if (!this.m_bCheckFBO)
         {
             if (this.Call_GetVideoWidth() <= 0 || this.Call_GetVideoHeight() <= 0)
             {
                 return;
             }
             this.Resize();
             if (this.m_VideoTexture != null)
             {
                 if (this.m_VideoTextureDummy != null)
                 {
                     UnityEngine.Object.Destroy(this.m_VideoTextureDummy);
                     this.m_VideoTextureDummy = null;
                 }
                 this.m_VideoTextureDummy = this.m_VideoTexture;
                 this.m_VideoTexture      = null;
             }
             if (this.m_bSupportRockchip)
             {
                 this.m_VideoTexture      = new Texture2D(this.Call_GetVideoWidth(), this.Call_GetVideoHeight(), TextureFormat.RGB565, false);
                 this.m_VideoTexture.name = "MediaPlayCtrl_1_" + Time.time.ToString();
             }
             else
             {
                 this.m_VideoTexture      = new Texture2D(this.Call_GetVideoWidth(), this.Call_GetVideoHeight(), TextureFormat.RGBA32, false);
                 this.m_VideoTexture.name = "MediaPlayCtrl_2_" + Time.time.ToString();
             }
             this.m_VideoTexture.filterMode = FilterMode.Bilinear;
             this.m_VideoTexture.wrapMode   = TextureWrapMode.Clamp;
             this.Call_SetUnityTexture(this.m_VideoTexture.GetNativeTextureID());
             this.Call_SetWindowSize();
             this.m_bCheckFBO = true;
         }
         this.Call_UpdateVideoTexture();
         this.m_iCurrentSeekPosition = this.Call_GetSeekPosition();
     }
     if (this.m_CurrentState != this.Call_GetStatus())
     {
         this.m_CurrentState = this.Call_GetStatus();
         if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.READY)
         {
             if (this.OnReady != null)
             {
                 this.OnReady();
             }
             if (this.m_bAutoPlay)
             {
                 this.Call_Play(0);
             }
             this.SetVolume(this.m_fVolume);
         }
         else if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.END)
         {
             if (this.OnEnd != null)
             {
                 this.OnEnd();
             }
             if (this.m_bLoop)
             {
                 this.Call_Play(0);
             }
         }
         else if (this.m_CurrentState == MediaPlayerCtrl.MEDIAPLAYER_STATE.ERROR)
         {
             this.OnError((MediaPlayerCtrl.MEDIAPLAYER_ERROR) this.Call_GetError(), (MediaPlayerCtrl.MEDIAPLAYER_ERROR) this.Call_GetErrorExtra());
         }
     }
 }