示例#1
0
        private void Renderer_PlaybackStopped(object sender, NAudio.Wave.StoppedEventArgs e)
        {
            if (e.Exception != null)
            {
                Utils.Notification ne = new Utils.Notification(ParentGrid, e.Exception.Message, null,
                                                               Constants.ErrorBrush);
                ne.ShowMessage();
            }

            if (Repeat.ToggleState == MVPUC.Toggles.Repeat.State.SingleRepeat)
            {
                ReRenderFile(false, true);
            }
            else
            {
                Manager.PlayNext();
            }
        }
示例#2
0
        public bool RenderFile(LAPP.IO.MediaFile File, bool AutoRun = true)
        {
            try
            {
                InitializeRenderer(File);

                TitleT.Content  = File.Title;
                ArtistT.Content = File.Artist;
                AlbumT.Content  = File.Album;
                //TODO Plugin Events
            }
            catch (Exception ex)
            {
                Dialogs.LogWindow.Append(ex.Message);
                StopFile(true);
                Utils.Notification na = new Utils.Notification(ParentGrid,
                                                               Localize.Get("RENDERING_ERROR"), Constants.ErrorBrush);
                na.ShowMessage();
                return(false);
            }

            SeekBar.Maximum = Renderer.AudioFileReader.Length;
            ApplyVolume();

            Utils.Animation.Visible ta = new Utils.Animation.Visible();
            ta.Animate(Config.Current.Animation[Enums.Animation.Default], TimeL, Visibility.Visible);

            seekt.Interval = 20;
            seekt.Start();
            seekt.Tick += Seekt_Tick;

            MC.MediaStateButton.SwitchMediaState();

            bgImage.Image = File.Artwork;

            if (bgImage.Visibility == Visibility.Hidden)
            {
                Utils.Animation.Visible va = new Utils.Animation.Visible();
                va.Animate(Config.Current.Animation[Enums.Animation.BackgroundImage], bgImage, Visibility.Visible);
            }

            MC.PlayingStatus.Title = File.Title;
            MC.PlayingStatus.Album = File.Album;
            MC.PlayingStatus.Image = File.Artwork;
            MC.VisibleStatus();

            PlayingFile = File;

            TaskbarManager.VisibleButtons();

            if (AutoRun)
            {
                RunFile();
            }

            PluginPanel.Children.Clear();
            FrameworkElement[] elements = Utils.PluginManager.GetMediaPanelItems().ToArray();
            for (int i = 0; elements.Length > i; i++)
            {
                PluginPanel.Children.Add(elements[i]);
            }

            return(true);
        }
示例#3
0
        public void ReRenderFile(bool StayPosition, bool StayStatus)
        {
            if (PlayingFile == null)
            {
                return;
            }

            long pos = 0;

            Audio.Status status = Audio.Status.Playing;

            if (Renderer != null && Renderer.AudioFileReader != null)
            {
                if (StayPosition)
                {
                    pos = Renderer.AudioFileReader.Position;
                }
                if (StayStatus)
                {
                    status = Renderer.StreamStatus;
                    if (status == Audio.Status.Stopped)
                    {
                        return;
                    }
                }
            }

            Renderer.StreamStatus = Audio.Status.Stopped;
            try
            {
                InitializeRenderer(PlayingFile);
            }
            catch (Exception ex)
            {
                Dialogs.LogWindow.Append(ex.Message);
                StopFile(true);
                Utils.Notification na = new Utils.Notification(ParentGrid,
                                                               Localize.Get("RENDERING_ERROR"), Constants.ErrorBrush);
                na.ShowMessage();
                return;
            }

            Renderer.AudioFileReader.Position = pos;

            seekt.Interval = 20;
            seekt.Start();
            seekt.Tick += Seekt_Tick;

            ApplyVolume();

            switch (status)
            {
            case Audio.Status.Playing:
                RunFile();
                break;

            case Audio.Status.Paused:
                PauseFile();
                break;
            }
        }