示例#1
0
文件: BassMet.cs 项目: Anderwafe/APBA
        public static void Play(Playlists PlayItem)
        {
            if (Bass.BASS_GetInfo() == null)
            {
                Bass.BASS_Init(-1, hz, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            }
            Bass.BASS_StreamFree(_stream);
            Bass.BASS_ChannelStop(_stream);

            _stream = Bass.BASS_StreamCreateFile(PlayItem.Path, 0, 0, BASSFlag.BASS_DEFAULT);
            now     = PlayList.IndexOf(PlayItem);
            Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, slrVolume / 100f);

            EqualizerSettings.SetFX(_stream);

            ggg.Dispatcher.Invoke(() =>
            {
                ggg.lblAudioName.Content = PlayItem.Name;
                ggg.SyncSlider();
                ggg.lblMusicDuration.Content = new TimeSpan(0, 0, (int)Bass.BASS_ChannelBytes2Seconds(BassMet._stream, Bass.BASS_ChannelGetLength(BassMet._stream)));
                ggg.btnResumePause.Content   = "Pause";
            });


            Bass.BASS_ChannelPlay(_stream, true);
            timer.Start();
        }
示例#2
0
        public ReadPlaylistDialog()
        {
            InitializeComponent();

            Activated += (e, a) =>
            {
                try
                {
                    var b = Directory.GetFiles(Playlists.PLPath, "*.m3u");
                    if (b == null)
                    {
                        MessageBox.Show("Плейлисты не найдены", "Ошибка", MessageBoxButton.OK);
                    }
                    else
                    {
                        for (int i = 0; i < b.Length; i++)
                        {
                            LPlaylists.Add(b[i].Substring(b[i].LastIndexOfAny(new char[] { '\\', '/' }) + 1));
                        }

                        //lvOpenPlaylist.DisplayMemberPath = LPlaylists[0].ToString();
                        lvOpenPlaylist.ItemsSource = LPlaylists;
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("Плейлисты не найдены", "Ошибка", MessageBoxButton.OK);
                    Directory.CreateDirectory(Playlists.PLPath);
                }
            };

            lvOpenPlaylist.MouseDoubleClick += (e, a) =>
            {
                try
                {
                    if (LPlaylists.Count == 0)
                    {
                        return;
                    }
                    Playlists.PlayListRead(LPlaylists[lvOpenPlaylist.SelectedIndex]);
                    Close();
                }
                catch
                { }
            };
        }
示例#3
0
 public SavePlaylistDialog()
 {
     InitializeComponent();
     SavePlaylistOK.Click += (e, a) =>
     {
         Dispatcher.InvokeAsync(() => {
             if (Playlists.PlayListSave(SavePlaylistName.Text, BassMet.PlayList))
             {
                 DialogResult = true;
                 Close();
             }
             else
             {
                 MessageBox.Show("Плейлист с таким названием уже существует!", "Ошибка", MessageBoxButton.OK);
             }
         });
     };
 }