Esempio n. 1
0
        private void PlayVideo()
        {
            if (_video != null)
            {
                //_video.MovieView.SetFrameOrigin(new System.Drawing.PointF(0,0));
                //_video.MovieView.SetFrameSize(new System.Drawing.SizeF(_game.GraphicsDevice.PresentationParameters.BackBufferWidth,_game.GraphicsDevice.PresentationParameters.BackBufferHeight));
                _video.MovieView.Frame = new System.Drawing.RectangleF(0, 0, _game.GraphicsDevice.PresentationParameters.BackBufferWidth, _game.GraphicsDevice.PresentationParameters.BackBufferHeight);

                /*  A primitive way of launching the media player
                 * MonoMac.AppKit.NSWorkspace workspace = MonoMac.AppKit.NSWorkspace.SharedWorkspace;
                 * workspace.OpenUrls(new[]{NSUrl.FromString(_video.FileName)},
                 *   @"com.apple.quicktimeplayer",
                 *   MonoMac.AppKit.NSWorkspaceLaunchOptions.Async,
                 *   new NSAppleEventDescriptor(),
                 *   new[]{""}); */

                // TODO when Xamarin implement the relevant functions var theError = QTOpenGLTextureContextCreate( null, null, _game.Window.PixelFormat, _game.Window.OpenGLContext, out textureContext);

                _game.Window.AddSubview(_video.MovieView);

                NSNotificationCenter.DefaultCenter.AddObserver(new NSString("QTMovieDidEndNotification"), (notification) =>
                {
                    Stop();
                    if (_isLooped)
                    {
                        PlayVideo();
                    }
                });
                _video.MovieView.Play(new NSObject());

                _state             = MediaState.Playing;
                Game._playingVideo = true;
            }
        }
Esempio n. 2
0
 public void Stop()
 {
     _video.MovieView.MoviePlayer.Stop();
     _state             = MediaState.Stopped;
     Game._playingVideo = false;
     _video.MovieView.View.RemoveFromSuperview();
 }
Esempio n. 3
0
        private static void PlatformInitialize()
        {
            PhoneApplicationService.Current.Activated += (sender, e) =>
                {
                    if (_mediaElement != null)
                    {
                        if (_mediaElement.Source == null && source != null)
                        {
                            _mediaElement.AutoPlay = false;
                            Deployment.Current.Dispatcher.BeginInvoke(() => _mediaElement.Source = source);
                        }

                        // Ensure only one subscription
                        _mediaElement.MediaOpened -= MediaElement_MediaOpened;
                        _mediaElement.MediaOpened += MediaElement_MediaOpened;
                    }
                };

            PhoneApplicationService.Current.Deactivated += (sender, e) => 
                {
                    if (_mediaElement != null)
                    {
                        source = _mediaElement.Source;
                        elapsedTime = _mediaElement.Position;

                        wasDeactivated = true;
                        deactivatedState = _state;
                    }
                };
        }
        private void MediaEngine_MediaStateChanged(MediaState state)
        {
            switch (state)
            {
                case MediaState.Loading:
                    this.PlaybackState = PlaybackState.Loading;

                    break;

                case MediaState.Stopped:
                    this.PlaybackState = PlaybackState.Paused;

                    break;

                case MediaState.Playing:
                    this.PlaybackState = PlaybackState.Playing;
                    break;

                case MediaState.Error:
                    this.PlaybackState = PlaybackState.Error_MediaInvalid;
                    break;

                case MediaState.Ended:
                    this.PlaybackState = PlaybackState.Ended;
                    break;
            }
        }
Esempio n. 5
0
        public void ChangeState(int id, MediaState newState)
        {
            var media = MediaRepository.GetById(id);

            media.State = newState;
            MediaRepository.Save(media);
        }
Esempio n. 6
0
        /// <summary>
        /// Executes the actions associated to a MediaState
        /// </summary>
        /// <param name="state">The MediaState to execute</param>
        protected void ExecuteMediaState(MediaState state)
        {
            switch (state)
            {
            case MediaState.Manual:
                break;

            case MediaState.Play:
                Play();
                break;

            case MediaState.Stop:
                Stop();
                break;

            case MediaState.Close:
                Close();
                break;

            case MediaState.Pause:
                Pause();
                break;

            default:
                throw new ArgumentOutOfRangeException("state");
            }
        }
        private void MediaEngine_MediaStateChanged(MediaState state)
        {
            switch (state)
            {
            case MediaState.Loading:
                PlaybackState = PlaybackState.Loading;

                break;

            case MediaState.Stopped:
                PlaybackState = PlaybackState.Paused;

                break;

            case MediaState.Playing:
                PlaybackState = PlaybackState.Playing;
                break;

            case MediaState.Error:
                PlaybackState = PlaybackState.Error_MediaInvalid;
                break;

            case MediaState.Ended:
                PlaybackState = PlaybackState.Ended;
                break;
            }
        }
Esempio n. 8
0
        public void Close(bool force = false)
        {
            logger.Debug("VideoHttpStreamer::Close()");

            Stop();

            if (!force)
            {
                if (streamTask != null)
                {
                    if (streamTask.Status == TaskStatus.Running)
                    {
                        bool waitResult = false;
                        do
                        {
                            waitResult = streamTask.Wait(1000);
                            if (!waitResult)
                            {
                                logger.Warn("VideoHttpStreamer::Close() " + waitResult);
                            }
                        } while (!waitResult);
                    }
                }
            }

            screenSource.BufferUpdated -= ScreenSource_BufferUpdated;

            if (encoder != null)
            {
                encoder.DataEncoded -= Encoder_DataEncoded;
                encoder.Close();
            }

            state = MediaState.Closed;
        }
        private void PlayOrPauseButton_Click(object sender, RoutedEventArgs e)
        {
            MediaState mediaState = GetMediaState(myMediaElement);

            //MessageBox.Show(mediaState.ToString());
            if (mediaState == MediaState.Play)
            {
                myMediaElement.Pause();
                PlayOrPauseImg.Source = new BitmapImage(new Uri(@"\images\play.png", UriKind.Relative));

                //MessageBox.Show(Media.Position.ToString());
                //Media.Position
                //Media.NaturalDuration.TimeSpan;
                //Media.HasAudio;
            }
            else if (mediaState == MediaState.Pause || mediaState == MediaState.Close || mediaState == MediaState.Stop)
            {
                myMediaElement.Play();
                while (GetMediaState(myMediaElement) != MediaState.Play)
                {
                    ;
                }

                CheckAndStartThraed();

                if (updateThread.ThreadState == ThreadState.Stopped)
                {
                    //updateThread.Start();
                }
                PlayOrPauseImg.Source = new BitmapImage(new Uri(@"\images\pause.png", UriKind.Relative));
            }
        }
        protected MediaStateCollectionView(MediaState mediaState = null)
        {
            eventQueue = new ConcurrentQueue <object>();

            MediaCollectionView = new SelectableMediaLockedCollection();
            this.MediaState     = mediaState;

            sortedItemEnd = 0;

            SortFunc = new Func <SelectableMediaItem, SelectableMediaItem, int>((a, b) =>
            {
                return(a.ToString().CompareTo(b.ToString()));
            });

            Filter = new Func <SelectableMediaItem, bool>((a) =>
            {
                return(true);
            });

            SortDirection = ListSortDirection.Ascending;

            TagFilter = new List <TagItem>();

            Guid = Guid.NewGuid();
        }
Esempio n. 11
0
 public ExtendedPlayer()
 {
     State = MediaState.Stopped;
     ChangedByUserHands = false;
     this.Volume        = 0.5;
     this.Pause();
 }
Esempio n. 12
0
        public Media()
        {
            _path  = null;
            _state = MediaState.Stop;

            Tweeted = false;
        }
Esempio n. 13
0
 public void Stop()
 {
     _video.Player.Stop();
     _state             = MediaState.Stopped;
     Game._playingVideo = false;
     _video.Player.SetDisplay(null);
 }
Esempio n. 14
0
 public void Update()
 {
     if (add.ShouldPlay)
     {
         try
         {
             var ctor = typeof(Song).GetConstructor(
                 BindingFlags.NonPublic | BindingFlags.Instance, null,
                 new[] { typeof(string), typeof(string), typeof(int) }, null);
             Song currSong =
                 (Song)
                 ctor.Invoke(new object[]
             {
                 add.currentSong,
                 @"c:/users/" + Environment.UserName + "/Documents/RubikCube/Songs/" +
                 add.currentSong,
                 0
             });
             MediaPlayer.Play(currSong);
         }
         catch (Exception)
         { }
         add.ShouldPlay = false;
     }
     oldState = MediaPlayer.State;
 }
        private async void ScenarioEnable(object sender, RoutedEventArgs e)
        {
            if (_accelerometer != null)
            {
                // Establish the report interval
                _accelerometer.ReportInterval = _desiredReportInterval;
                isPause = false;
                Window.Current.VisibilityChanged += new WindowVisibilityChangedEventHandler(VisibilityChanged);
                _accelerometer.ReadingChanged    += new TypedEventHandler <Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);


                ScenarioPauseButton.IsEnabled   = true;
                ScenarioDisableButton.IsEnabled = true;
                timeStart = DateTime.Now.Ticks;
                state     = MediaState.Playing;
                ScenarioEnableButton.IsEnabled = false;
                timeThread = ThreadPoolTimer.CreatePeriodicTimer(UpdateTime, TimeSpan.FromMilliseconds(1000));
            }
            else
            {
                var ketQua = new MessageDialog("Điện thoại của bạn không có thiết bị để hổ trợ bài tập");
                await ketQua.ShowAsync();

                if (Frame.CanGoBack)
                {
                    Frame.GoBack();
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Resumes a paused video.
        /// </summary>
        public void Resume()
        {
            if (_currentVideo == null)
            {
                return;
            }

            var state = State;

            // No work to do if we're already playing
            if (state == MediaState.Playing)
            {
                return;
            }

            if (state == MediaState.Stopped)
            {
                PlatformPlay();
                return;
            }

            PlatformResume();

            _state = MediaState.Playing;
        }
Esempio n. 17
0
        /// <summary>
        /// Pause media
        /// </summary>
        /// <returns></returns>
        public int Pause()
        {
            TRACE("Media::Pause");

            if (m_state != MediaState.Started)
            {
                return(E_Fail);
            }
            if (m_pSession == null || m_pSource == null)
            {
                return(E_Unexpected);
            }

            int hr = S_Ok;

            try
            {
                m_pSession.Pause();

                m_state = MediaState.PausePending;
                NotifyState();
            }
            catch (Exception e)
            {
                hr = Marshal.GetHRForException(e);
                NotifyError(hr);
            }

            return(hr);
        }
Esempio n. 18
0
        private async void OnMediaStateChanged(MediaState mediaState)
        {
            switch (mediaState)
            {
            case MediaState.Opened:
                _attempToPlay = 0;
                var trackId = Playlist.Current;
                if (trackId > 0)
                {
                    CurrentTrack = await _dataService.GetTrackById(trackId);

                    UpdateHistory(CurrentTrack);
                }
                break;

            case MediaState.Ended:
                if (AudioPlayerMode != AudioPlayerMode.None && AudioPlayerMode != AudioPlayerMode.Song && CanPlayNextTrack())
                {
                    PlayNextTrack();
                }
                break;

            case MediaState.BadRequest:
                Console.WriteLine($"{nameof(OnMediaStateChanged)} bad request");
                if (AudioPlayerMode != AudioPlayerMode.None && AudioPlayerMode != AudioPlayerMode.Song && CanPlayNextTrack())
                {
                    //If we have a bad request, we try to play the track another time;
                    TryToPlayTrack();
                }
                break;
            }
            _eventAggregator.GetEvent <MediaStateChangedEvent>().Publish(mediaState);
        }
        void MediaPlayer_MediaOpened(object sender, RoutedEventArgs e)
        {
            //(IVideoElement as Window).Dispatcher.Invoke(new Action(() =>
            //{
            if (IVideoPlayer == null)
            {
                return;
            }
            if (IVideoElement.MediaPlayer.HasVideo)
            {
                SetControllerDetails();
                MediaState = MediaState.Playing;
                MediaPositionTimer.Start();
                CurrentVideoItem.IsActive = true;
                if (CurrentVideoItem.HasLastSeen)
                {
                    IVideoElement.MediaPlayer.Position = TimeSpan.
                                                         FromSeconds(CurrentVideoItem.LastPlayedPoisition.ProgressLastSeen);
                }
                //if (CurrentVideoItem.HasLastSeen)
                //{
                //    IVideoPlayer.MediaPlayer.MediaPosition =
                //    (long)CurrentVideoItem.LastPlayedPoisition.ProgressLastSeen * 10000000;
                //}
                CommandManager.InvalidateRequerySuggested();

                ((IVideoPlayer as SubtitleMediaController).DataContext as VideoPlayerVM)
                .VisibilityAnimation();
                DragPositionSlider.IsEnabled = true;
            }
            // }), null);
        }
Esempio n. 20
0
        /// <summary>
        /// Plays a Video.
        /// </summary>
        /// <param name="video">Video to play.</param>
        public void Play(Video video)
        {
            if (video == null)
            {
                throw new ArgumentNullException("video is null.");
            }

            if (_currentVideo == video)
            {
                var state = State;

                // No work to do if we're already
                // playing this video.
                if (state == MediaState.Playing)
                {
                    return;
                }

                // If we try to Play the same video
                // from a paused state, just resume it instead.
                if (state == MediaState.Paused)
                {
                    PlatformResume();
                    return;
                }
            }

            _currentVideo = video;

            PlatformPlay();

            _state = MediaState.Playing;
        }
Esempio n. 21
0
 public void Stop()
 {
     _video.Player.Stop();
     _state = MediaState.Stopped;
     AndroidGamePlatform.IsPlayingVdeo = false;
     _video.Player.SetDisplay(null);
 }
Esempio n. 22
0
        private static void PlatformInitialize()
        {
            PhoneApplicationService.Current.Activated += (sender, e) =>
            {
                if (_mediaElement != null)
                {
                    if (_mediaElement.Source == null && source != null)
                    {
                        _mediaElement.AutoPlay = false;
                        Deployment.Current.Dispatcher.BeginInvoke(() => _mediaElement.Source = source);
                    }

                    // Ensure only one subscription
                    _mediaElement.MediaOpened -= MediaElement_MediaOpened;
                    _mediaElement.MediaOpened += MediaElement_MediaOpened;
                }
            };

            PhoneApplicationService.Current.Deactivated += (sender, e) =>
            {
                if (_mediaElement != null)
                {
                    source      = _mediaElement.Source;
                    elapsedTime = _mediaElement.Position;

                    wasDeactivated   = true;
                    deactivatedState = _state;
                }
            };
        }
Esempio n. 23
0
        private void OnMediaStateChanged(object sender, EventArgs e)
        {
            // if the media player state was paused due to an engine pause, don't
            // store the last state.

            if (MediaPlayer.State == MediaState.Paused && IsEnginePaused)
            {
                return;
            }

            _lastMediaState = MediaPlayer.State;
            if (MediaState.Stopped == _lastMediaState)
            {
                if (string.IsNullOrEmpty(NextSongName))
                {
                    CurrentSongName = null;
                    CurrentSong     = null;
                }
                else
                {
                    PlaySong(NextSongName);
                    NextSongName = null;
                }
            }
        }
Esempio n. 24
0
        private void Stop()
        {
            _notifyIcon.Visible = false;

            try
            {
                if (_registered)
                {
                    _registered = false;

                    IrssMessage message = new IrssMessage(MessageType.UnregisterClient, MessageFlags.Request);
                    _client.Send(message);
                }
            }
            catch
            {
            }

            StopClient();

            if (_mediaState != null)
            {
                _mediaState.Dispose();
                _mediaState = null;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Handle SessionPaused Event
        /// </summary>
        /// <param name="pEvent"></param>
        protected void OnSessionPaused(IMFMediaEvent pEvent)
        {
            TRACE("Media::OnSessionPaused");

            m_state = MediaState.Paused;
            NotifyState();
        }
Esempio n. 26
0
        internal bool Start()
        {
            try
            {
                LoadSettings();

                LoadExternalConfig();

                if (String.IsNullOrEmpty(_serverHost))
                {
                    if (!Configure())
                    {
                        return(false);
                    }
                }

                bool clientStarted = false;

                try
                {
                    IPAddress  serverIP = Network.GetIPFromName(_serverHost);
                    IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

                    clientStarted = StartClient(endPoint);
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                    MessageBox.Show("Failed to start IR Server communications, refer to log file for more details.",
                                    "Media Center Blaster - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    clientStarted = false;
                }

                if (clientStarted)
                {
                    _notifyIcon.Visible = true;

                    _mediaState                  = new MediaState();
                    _mediaState.OnMSASEvent     += new MediaState.MSASEventHandler(OnMSASEvent);
                    _mediaState.TV.MediaChanged += new EventHandler(TV_MediaChanged);

                    _mediaState.Connect();

                    return(true);
                }
                else
                {
                    Configure();
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                _mediaState = null;
            }

            return(false);
        }
 internal void RaiseMediaStateChangedEvent(MediaState oldValue, MediaState newValue)
 {
     GuiContext.Current.EnqueueInvoke(() =>
     {
         RaiseEvent(new MediaStateChangedRoutedEventArgs(
                        MediaStateChangedEvent, this, oldValue, newValue));
     });
 }
Esempio n. 28
0
        public static void Pause()
        {
			if (_song != null)
			{
				_song.Pause();
				_mediaState = MediaState.Paused;
			}			
        }
Esempio n. 29
0
        /*
        public Texture2D GetTexture()
        {
			// Coming Soon
			throw new NotImplementedException();
			// TODO when Xamarin implement the relevant functions return currentFrame;
        }
        */

        public void Pause()
        {
			if (_video != null )
			{
				_video.MovieView.Pause(new NSObject());
				_state = MediaState.Paused;
			}
        }
Esempio n. 30
0
        public static void Resume()
        {
			if (_song != null)
			{
				_song.Resume();
				_mediaState = MediaState.Playing;
			}					
        }
        public VideoPlayer()
        {
			_state = MediaState.Stopped;
			_game = Game.Instance;
            _platform = (iOSGamePlatform)_game.Services.GetService(typeof(iOSGamePlatform));
            if (_platform == null)
                throw new InvalidOperationException("No iOSGamePlatform instance was available");
        }
Esempio n. 32
0
 private void playSoundButton_Click(object sender, RoutedEventArgs e)
 {
     if ((state == MediaState.Stopped) || (state == MediaState.Paused))
     {
         state = MediaState.Playing;
         myMediaElement.Play();
     }
 }
Esempio n. 33
0
 public static void Stop()
 {
     if (_song != null)
     {
         _song.Stop();
         _mediaState = MediaState.Stopped;
     }
 }
Esempio n. 34
0
 public static void Pause()
 {
     if (_song != null)
     {
         _song.Pause();
         _mediaState = MediaState.Paused;
     }
 }
Esempio n. 35
0
 public static void Resume()
 {
     if (_song != null)
     {
         _song.Play();
         _mediaState = MediaState.Playing;
     }
 }
Esempio n. 36
0
        SetLoadedBehavior(
            MediaState loadedBehavior
            )
        {
            _loadedBehavior = loadedBehavior;

            HandleStateChange();
        }
Esempio n. 37
0
 public static void Play(Song song)
 {
     AudioSource.Stop();
     AudioSource.clip = song.AudioClip;
     AudioSource.Play();
     _currentSongRemainingSeconds = song.AudioClip.length * 0.95f;             // fudge it a bit as music stops when we lose focus
     State = MediaState.Playing;
 }
Esempio n. 38
0
 private void stopSoundButton_Click(object sender, RoutedEventArgs e)
 {
     if (state == MediaState.Playing)
     {
         state = MediaState.Stopped;
         myMediaElement.Stop();
     }
 }
Esempio n. 39
0
 protected override void OnStateChanged(MediaState state)
 {
     if (state == MediaState.End) return;
     if (Album != null)
         Album.State = State;
     foreach (var artist in Artists)
         artist.State = state;
 }
Esempio n. 40
0
 private void pauseSoundButton_Click(object sender, RoutedEventArgs e)
 {
     if (state == MediaState.Playing)
     {
         state = MediaState.Paused;
         myMediaElement.Pause();
     }
 }
Esempio n. 41
0
        public Sound(Game game)
        {
            this.game = game;

            music = new Music();
            soundEffect = new SoundEffect();
            state = new MediaState();
        }
Esempio n. 42
0
 private void playVideoButton_Click(object sender, RoutedEventArgs e)
 {
     if ((state == MediaState.Stopped) || (state == MediaState.Paused))
     {
         myMediaElement.Source = new Uri("ms-appx:///Assets/video.mp4", UriKind.RelativeOrAbsolute);
         state = MediaState.Playing;
         myMediaElement.Play();
     }
 }
Esempio n. 43
0
        public static void Play(Song song)
        {
			if ( song != null )
			{
				_song = song;
				_song.Volume = _volume;
				_song.Loop = _looping;
				_song.Play();
				_mediaState = MediaState.Playing;
			}
        }
Esempio n. 44
0
        public UmdDevice( IEmulationInstance emulator, ComponentParameters parameters )
        {
            //Debug.Assert( emulator != null );
            Debug.Assert( parameters != null );

            _emulator = emulator;
            _parameters = parameters;

            _state = MediaState.Ejected;

            _lbnLookup = new Dictionary<long, MediaFile>( 1024 );
        }
Esempio n. 45
0
 public async void initValue()
 {
     musicList.Clear();
     await getFiles(musicList, folder);
     STT = 0;
     musicProperties = null;
     stream = null;
     state = MediaState.STOP;
     pb = Playback.ORDER;
     rp = Repeat.ALL;
     nof = NumOfLoad.FIRST;
 }
        public void SetVideoPlayerState(MediaState state)
        {
            switch(state)
            {
                case MediaState.Paused:
                    {
                        this._VideoPlayer.Pause();
                        break;
                    }

                case MediaState.Stopped:
                    {
                        this._VideoPlayer.Stop();
                        break;
                    }

                default:
                    break;
            }
        }
Esempio n. 47
0
        private void PlatformGetState(ref MediaState result)
        {
            if (_clock != null)
            {
                ClockState state;
                _clock.GetState(0, out state);

                switch (state)
                {
                    case ClockState.Running:
                        result = MediaState.Playing;
                        return;

                    case ClockState.Paused:
                        result = MediaState.Paused;
                        return;
                }
            }

            result = MediaState.Stopped;
        }
Esempio n. 48
0
        private void playVideoButton_Click(object sender, RoutedEventArgs e)
        {
          //myMediaElement.Source = new Uri("ms-appx:///Assets/coffee.mp4", UriKind.RelativeOrAbsolute);
          //myMediaElement.Play();

          if (state == MediaState.Stopped)
          {
            myMediaElement.Source = new Uri("ms-appx:///Assets/coffee.mp4", UriKind.RelativeOrAbsolute);
            state = MediaState.Playing;
            myMediaElement.Play();
          }
          else if (state == MediaState.Playing)
          {
            state = MediaState.Paused;
            myMediaElement.Pause();
          }
          else if (state == MediaState.Paused)
          {
            state = MediaState.Playing;
            myMediaElement.Play();
          }

        }
 private void MediaPlayerPlay()
 {
     _mediaPlayer.Play();
     PlayerState = MediaState.Play;
     _timer.Start();
 }
Esempio n. 50
0
        public VideoPlayer(Game game)
        {
			_state = MediaState.Stopped;
			_game = game;
        }
Esempio n. 51
0
		private void PlayVideo()
		{				
			_game.Window.AddSubview(_video.MovieView.View);			
			
			NSNotificationCenter.DefaultCenter.AddObserver("MPMoviePlayerPlaybackDidFinishNotification",(NSNotification) => OnStop(null),_video.MovieView.MoviePlayer);		

			_video.MovieView.MoviePlayer.Play();
			_state = MediaState.Playing;			
			Game._playingVideo = true;			

		}
 private void mainClock_CurrentTimeInvalidated(object sender, EventArgs e)
 {
     TimeDelay -= TimeDelta;
     if (TimeDelay <= 0)
     {
         TimeDelay =2f;
         if (this.MediaState == MTC_Player.MediaState.None || MediaState == MTC_Player.MediaState.Playing)
         {
             MediaData media= null;
             try
             {
                 media = App.curDevice.Media;
             }
             catch (LogoutException )
             {
                 MessageBox.Show("Thiết bị đã bị khóa! Hãy liên hệ với admin");
                 this.Close();
             }
             if (media != null && media.ID != 0)
             {
                 if (this.checkFile(media).Value)
                 {
                     if (App.curDevice.MediaChange)
                     {
                         this.PlayMedia(media.Media);
                         this.txt_alta_media_name.Text = media.Name;
                     }
                     else if (!myVlcControl.IsPlaying)
                     {
                         myVlcControl.Position = 0;
                         myVlcControl.Play();
                     }
                 }
                 else
                 {
                     this.MediaState = MTC_Player.MediaState.Dowloading;
                     myVlcControl.Stop();
                     barTimeSeek.Value = 0;
                     UIFtp.Local = media.LocalFile.FullName;
                     UIFtp.Url = media.Url;
                     UIFtp.FtpUser = App.setting.ftp_user;
                     UIFtp.FtpPassword = App.setting.ftp_password;
                     UIFtp.RunDownLoad();
                     this.UIFtp.Visibility = Visibility.Visible;
                     this.txt_alta_media_name.Text = media.Name + " download ...";
                 }
             }
             else
             {
                 this.MediaState = MTC_Player.MediaState.None;
                 myVlcControl.Stop();
                 this.txt_alta_media_name.Text = string.Empty;
                 barTimeSeek.Value = 0;
             }
         }
     }
 }
Esempio n. 53
0
        public void Stop()
        {
			_video.MovieView.MoviePlayer.Stop();
			_state = MediaState.Stopped;
			Game._playingVideo = false;
			_video.MovieView.View.RemoveFromSuperview();
        }
 private void PlayMedia(MediaBase media)
 {
     if (media != null)
     {
         if (myVlcControl.Medias != null && myVlcControl.Medias.Count > 0)
             myVlcControl.Medias.Clear();
         media.StateChanged -= media_StateChanged;
         media.StateChanged += media_StateChanged;
         media.ParsedChanged -= media_ParsedChanged;
         media.ParsedChanged += media_ParsedChanged;
         myVlcControl.Media = media;
         myVlcControl.Play();
         this.MediaState = MTC_Player.MediaState.Playing;
     }
 }
Esempio n. 55
0
 public static void Stop()
 {
     if (_song != null)
     {
         _song.Stop();
         _mediaState = MediaState.Stopped;
     }
 }
 private void UIFtp_CompleteEvent(object sender, string e)
 {
     this.UIFtp.Visibility = Visibility.Collapsed;
     this.MediaState = MTC_Player.MediaState.None;
 }
 void Tcp_Server_PlayVlc(object sender, System.Net.EndPoint e)
 {
     this.Dispatcher.Invoke(() =>
     {
         topImage.Animation_Opacity_View_Frame(false);
     });
     this.MediaState = MTC_Player.MediaState.None;
     this.mainClock.Controller.Resume();
 }
 void Tcp_Server_StopVlc(object sender, System.Net.EndPoint e)
 {
     this.MediaState = MTC_Player.MediaState.Stop;
     this.mainClock.Controller.Pause();
     myVlcControl.Stop();
 }
	    // EnterBackground
        void Activity_Paused(object sender, EventArgs e)
        {
            if (IsActive)
            {
                IsActive = false;
				_MediaPlayer_PrevState = MediaPlayer.State;
				_gameWindow.GameView.Pause();
				_gameWindow.GameView.ClearFocus();
				if(Game.Activity.AutoPauseAndResumeMediaPlayer)
                	MediaPlayer.Pause();
            }
        }
        /// <inheritdoc /> 
        protected override void SetAdvertisingState(AdState adState)
#endif
        {
            var newValue = ConvertAdState(adState);
            var oldValue = MediaPlayer.AdvertisingState;

            if (newValue != oldValue)
            {
#if WINDOWS_PHONE7
                if (MediaPlayer.PlayerState == PlayerState.Started || playerState != null)
#else
                if (MediaPlayer.PlayerState == PlayerState.Started)
#endif
                {
                    // pause the MediaPlayer if we're playing a linear ad or loading an ad, resume if the opposite
                    if ((newValue == AdvertisingState.Loading || newValue == AdvertisingState.Linear) && (oldValue == AdvertisingState.None || oldValue == AdvertisingState.NonLinear))
                    {
#if WINDOWS_PHONE7
                        playerState = MediaPlayer.GetMediaState();
                        MediaPlayer.Close();
#else
                        MediaPlayer.Pause();
#endif
                    }
                    else if ((oldValue == AdvertisingState.Loading || oldValue == AdvertisingState.Linear) && (newValue == AdvertisingState.None || newValue == AdvertisingState.NonLinear))
                    {
#if WINDOWS_PHONE7
                        MediaPlayer.RestoreMediaState(playerState);
                        playerState = null;
#else
                        MediaPlayer.Play();
#endif
                    }
                }

                if (newValue == AdvertisingState.Loading)
                {
                    AdContainer.Visibility = Visibility.Visible;
                }
                else if (newValue == AdvertisingState.None)
                {
                    AdContainer.Visibility = Visibility.Collapsed;
                }

                // let the MediaPlayer update its visualstate
                MediaPlayer.AdvertisingState = newValue;
            }

            switch (newValue)
            {
                case AdvertisingState.Linear:
                    MediaPlayer.InteractiveViewModel = new VpaidLinearAdViewModel(ActiveAdPlayer, MediaPlayer);
                    break;
                case AdvertisingState.NonLinear:
                    MediaPlayer.InteractiveViewModel = new VpaidNonLinearAdViewModel(ActiveAdPlayer, MediaPlayer);
                    break;
                default:
                    MediaPlayer.InteractiveViewModel = MediaPlayer.DefaultInteractiveViewModel;
                    break;
            }
        }