예제 #1
0
 /// <summary>
 /// Event Handler for miscellaneous informational events
 /// </summary>
 /// <param name="info">The event that occurred</param>
 /// <param name="extra">The data associated with the event (if any), otherwise, 0</param>
 private void HandleInfo(MLMediaPlayerInfo info, int extra)
 {
     Debug.Log("MediaPlayerExample::HandleInfo " + info.ToString());
     if (info == MLMediaPlayerInfo.BufferingEnd)
     {
         // this is guaranteed to be called only when we're streaming
         // Note: we can't guarantee if this is last BufferingEnd event
         _updateTime = true;
         if (_wasPlaying)
         {
             _mediaPlayer.Play();
             _wasPlaying = false;
         }
     }
     else if (info == MLMediaPlayerInfo.NetworkBandwidth)
     {
         _isStreaming = true;
         // extra would contain bandwidth in kbps
     }
 }
예제 #2
0
 /// <summary>
 /// Handler when Play/Pause Toggle is triggered.
 /// See HandlePlay() and HandlePause() for more info
 /// </summary>
 /// <param name="shouldPlay">True when resuming, false when should pause</param>
 private void PlayPause(bool shouldPlay)
 {
     if (_mediaPlayer != null)
     {
         if (!shouldPlay && _mediaPlayer.IsPlaying)
         {
             _mediaPlayer.Pause();
         }
         else if (shouldPlay && !_mediaPlayer.IsPlaying)
         {
             _mediaPlayer.Play();
         }
     }
 }
 /// <summary>
 /// Handler when Play/Pause Toggle is triggered.
 /// See HandlePlay() and HandlePause() for more info
 /// </summary>
 private void PlayPause()
 {
     if (_mediaPlayer != null)
     {
         if (_mediaPlayer.IsPlaying)
         {
             _UIUpdateTimer = float.MaxValue;
             _mediaPlayer.Pause();
         }
         else
         {
             _UIUpdateTimer = float.MaxValue;
             _mediaPlayer.Play();
         }
     }
 }
예제 #4
0
 /// <summary>
 /// Handler when Play/Pause Toggle is triggered.
 /// See HandlePlay() and HandlePause() for more info
 /// </summary>
 /// <param name="shouldPlay">True when resuming, false when should pause</param>
 private void PlayPause(bool shouldPlay)
 {
     if (_mediaPlayer != null)
     {
         if (!shouldPlay && _mediaPlayer.IsPlaying)
         {
             _UIUpdateTimer = float.MaxValue;
             _mediaPlayer.Pause();
         }
         else if (shouldPlay && !_mediaPlayer.IsPlaying)
         {
             _UIUpdateTimer = float.MaxValue;
             _mediaPlayer.Play();
         }
     }
 }
예제 #5
0
 /// <summary>
 /// Handler when Play/Pause Toggle is triggered.
 /// See HandlePlay() and HandlePause() for more info
 /// </summary>
 private void PlayPause()
 {
     #if PLATFORM_LUMIN
     if (_mediaPlayer != null)
     {
         if (_mediaPlayer.IsPlaying)
         {
             _UIUpdateTimer = float.MaxValue;
             _mediaPlayer.Pause();
         }
         else
         {
             _UIUpdateTimer = float.MaxValue;
             _mediaPlayer.Play();
         }
     }
     #endif
 }
예제 #6
0
        async UniTask PlayVideo(string url)
        {
            _mediaPlayer.VideoSource = url;

            // Start observing OnMediaError before PrepareVideo because
            // PrepareVideo itself can trigger MediaError events
            var error    = _mediaPlayer.OnMediaErrorAsObservable().ToUniTask(useFirstValue: true);
            var complete = _mediaPlayer.OnVideoPreparedAsObservable().ToUniTask(useFirstValue: true);

            _mediaPlayer.PrepareVideo().ThrowIfFail();

            // Throw exception in case an error happens,
            // otherwise wait until preparation is completed
            await UniTask.WhenAny(error, complete);

            // Play video
            _mediaPlayer.IsLooping = true;
            _mediaPlayer.Play().ThrowIfFail();
        }
예제 #7
0
 /// <summary>
 /// Event Handler for when a video has been prepared and is ready to begin playback
 /// </summary>
 private void HandleVideoPrepared()
 {
     EnableUI(true);
     _mediaPlayer.IsLooping = true;
     _mediaPlayer.Play();
 }