コード例 #1
0
        private void ProgressBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            TimeSpan position = PodcastPlayer.getIntance().getTrackPlayPosition();
            TimeSpan duration = PodcastPlayer.getIntance().getTrackPlayDuration();

            CurrentPlayTime.Text = position.ToString("hh\\:mm\\:ss");
            TotalPlayTime.Text   = duration.ToString("hh\\:mm\\:ss");
        }
コード例 #2
0
ファイル: PodcastPlayer.cs プロジェクト: qeef/Podcatcher
        public static PodcastPlayer getIntance()
        {
            if (m_instance == null)
            {
                m_instance = new PodcastPlayer();
                BackgroundAudioPlayer.Instance.PlayStateChanged += m_instance.PlayStateChanged;
            }

            return(m_instance);
        }
コード例 #3
0
        private void audioStreaming(PodcastEpisodeModel podcastEpisode)
        {
            PodcastPlayer player = PodcastPlayer.getIntance();

            player.streamEpisode(podcastEpisode);
        }
コード例 #4
0
        public void play(PodcastEpisodeModel episode, bool startedFromPlayQueue = false)
        {
            if (episode == null)
            {
                Debug.WriteLine("Warning: Trying to play a NULL episode.");
                return;
            }

            Debug.WriteLine("Starting playback for episode: ");
            Debug.WriteLine(" Name: " + episode.EpisodeName);
            Debug.WriteLine(" File: " + episode.EpisodeFile);
            Debug.WriteLine(" Location: " + episode.EpisodeDownloadUri);

            // We have another episode currently playing, and we switch the episode that we are playing.
            if (CurrentlyPlayingEpisode != null &&
                (episode.EpisodeId != CurrentlyPlayingEpisode.EpisodeId))
            {
                CurrentlyPlayingEpisode.setNoPlaying();

                try
                {
                    CurrentlyPlayingEpisode.StoreProperty <long>("SavedPlayPos", BackgroundAudioPlayer.Instance.Position.Ticks);
                }
                catch (Exception)
                {
                    Debug.WriteLine("Could not set saved play pos; not available.");
                    CurrentlyPlayingEpisode.SavedPlayPos = 0;
                }
            }

            if (startedFromPlayQueue)
            {
                if (BackgroundAudioPlayer.Instance.PlayerState != PlayState.Paused ||
                    (CurrentlyPlayingEpisode != null &&
                     CurrentlyPlayingEpisode.EpisodeId != episode.EpisodeId))
                {
                    CurrentlyPlayingEpisode = episode;
                }
            }
            else
            {
                CurrentlyPlayingEpisode = episode;
                addSilentlyToPlayqueue(CurrentlyPlayingEpisode);
            }

            // Play locally from a downloaded file.
            if (CurrentlyPlayingEpisode != null &&
                CurrentlyPlayingEpisode.EpisodeDownloadState == PodcastEpisodeModel.EpisodeDownloadStateEnum.Downloaded)
            {
                PodcastPlayer player = PodcastPlayer.getIntance();
                player.playEpisode(CurrentlyPlayingEpisode);
            }
            else
            {
                // Stream it if not downloaded.
                if (isAudioPodcast(CurrentlyPlayingEpisode))
                {
                    audioStreaming(CurrentlyPlayingEpisode);
                }
                else
                {
                    PodcastPlayer player = PodcastPlayer.getIntance();
                    videoStreaming(episode);
                }
            }

            var handlerStartedPlaying = OnPodcastStartedPlaying;

            if (handlerStartedPlaying != null)
            {
                if (isAudioPodcast(episode))
                {
                    OnPodcastStartedPlaying(this, new EventArgs());
                }
            }

            App.mainViewModels.PlayQueue = new System.Collections.ObjectModel.ObservableCollection <PlaylistItem>(); // Notify playlist changed.
        }