Exemplo n.º 1
0
        private void MenuItem_UserSongList_Click(object sender, RoutedEventArgs e)
        {
            IList          LIST    = UserSongList.SelectedItems;
            int            total   = LIST.Count;
            SongInfoExpend curinfo = PlayListBase.PlayListSongs[PlayListBase.PlayListIndex - 1];

            for (int i = 0; i < total; i++)
            {
                PlayListBase.PlayListSongs.Remove((SongInfoExpend)LIST[0]);
            }
            int j;

            if (PlayListBase.PlayListSongs.Count == 0)
            {
                PlayListBase.PlayListIndex = 0;
                PlayListBase.SendMsg(MyMsgType.Stop, "");
            }
            else if ((j = PlayListBase.PlayListSongs.IndexOf(curinfo)) >= 0)
            {
                PlayListBase.PlayListIndex = j + 1;
            }
            else
            {
                PlayListBase.SendMsg(MyMsgType.Stop, "");
            }
        }
 /// <summary>
 /// 加入单曲到播放列表
 /// </summary>
 /// <param name="sinfo">要播放的曲目</param>
 /// <param name="IsPlayImmediately">是否要下一个播放</param>
 internal static void AddToPlayList(SongInfoExpend sinfo, bool IsPlayImmediately)
 {
     if (sinfo == null)
     {
         return;
     }
     if (ConfigPage.GlobalConfig.AddIndex == 1)
     {
         int index = PlayListIndex;
         PlayListSongs.Insert(index, new SongInfoExpend(sinfo));
         if (index == 0)
         {
             PlayListIndex = 1;            //PlayListIndex的逻辑造成当PlayListIndex=0时,PlayListIndex++=2
         }
         else
         if (IsPlayImmediately == true)
         {
             PlayListIndex++;
         }
     }
     else if (ConfigPage.GlobalConfig.AddIndex == 0)
     {
         PlayListSongs.Add(new SongInfoExpend(sinfo));
         if (IsPlayImmediately == true)
         {
             PlayListIndex = PlayListTotal;
         }
     }
 }
Exemplo n.º 3
0
        private void SearchList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SongInfoExpend se = ((FrameworkElement)(e.OriginalSource)).DataContext as SongInfoExpend;

            PlayList.PlayListBase.AddToPlayList(se, true);
            PlayList.PlayListBase.PlayAndExceptionPass();
        }
 internal static void AddToPlayList(SongInfoExpend sinfo, int index)
 {
     if (index > PlayListBase.PlayListSongs.Count - 1)
     {
         PlayListBase.PlayListSongs.Add(new SongInfoExpend(sinfo));
     }
     else
     {
         PlayListBase.PlayListSongs.Insert(index, new SongInfoExpend(sinfo));
     }
 }
Exemplo n.º 5
0
        void OnPlayingChanged(SongInfoExpend songInfoExpend)
        {
            LoadLoaclLrc(null, Dispatcher, LoadLrcSuccessToUI, LoadLrcFailToUI);
            InitLrcShow(Dispatcher);//性能问题:0.3-0.5s
            PlayingPageBackgroundUpdateUIDeleLink?.Invoke();

            notesViewData = new Note.NotesViewData(CurrentSongInfo.SongInfo);
            FirstNode     = notesViewData.Notes.First;
            Dispatcher.Invoke(() => PlayingGrid.Children.Clear());

            Dispatcher.Invoke(() => PlayingBorder.DataContext = CurrentSongInfo);
        }
Exemplo n.º 6
0
 void OnPlayingChanged(SongInfoExpend CurSongInfoEx)
 {
     Dispatcher.BeginInvoke((ThreadStart) delegate
     {
         UserSongList.SelectedItem = CurSongInfoEx; //选择为当前播放项
         ListBoxItem item          = (ListBoxItem)UserSongList.ItemContainerGenerator.ContainerFromItem(CurSongInfoEx);
         if (item != null)                          //使用虚拟化的锅,毕竟只是区区文字,还是不用虚拟化了吧
         {
             item.ContentTemplate = Resources["PlayListItemSelectedDataTemplate"] as DataTemplate;
             if (BeforPlayItem != null)
             {
                 BeforPlayItem.ContentTemplate = Resources["PlayListItemDataTemplate"] as DataTemplate;
             }
             BeforPlayItem = item;
         }
     });
 }
Exemplo n.º 7
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            PlayListBase.PlayingChanged += OnPlayingChanged;
            UserSongList.ItemsSource     = PlayListBase.PlayListSongs;
            PlayListAlbumImageShowListBox.ItemsSource = PlayListBase.PlayListSongs;
            if (PlayListBase.PlayListTotal <= 0)
            {
                return;
            }
            UserSongList.SelectedItem = PlayListBase.PlayListSongs[PlayListBase.PlayListIndex - 1];
            UserSongList.ScrollIntoView(UserSongList.SelectedItem);
            if (t1 == null)
            {
                t1 = new Timer(delegate
                { //用于等待项的生成
                    Dispatcher.Invoke((ThreadStart) delegate
                    {
                        SongInfoExpend sinfoEx = PlayListBase.PlayListSongs[PlayListBase.PlayListIndex - 1];
                        ListBoxItem item       = (ListBoxItem)UserSongList.ItemContainerGenerator.ContainerFromItem(sinfoEx);
                        if (item == null)
                        {
                            return;
                        }
                        item.ContentTemplate = CurInstance.Resources["PlayListItemSelectedDataTemplate"] as DataTemplate;
                        if (CurInstance.BeforPlayItem != null)
                        {
                            CurInstance.BeforPlayItem.ContentTemplate = CurInstance.Resources["PlayListItemDataTemplate"] as DataTemplate;
                        }
                        CurInstance.BeforPlayItem = item;
                    });
                }, null, 500, Timeout.Infinite);
            }
            else
            {
                t1.Change(500, Timeout.Infinite);
            }

            PlayListAlbumImageShowListBox.SelectedItem = PlayListBase.PlayListSongs[PlayListBase.PlayListIndex - 1];
            PlayListAlbumImageShowListBox.ScrollViewToCur(PlayListAlbumImageShowListBox.SelectedItem);
            //    myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(PlayListAlbumImageShowListBox.ItemsSource);
            //    myCollectionView.MoveCurrentToFirst();
        }
Exemplo n.º 8
0
        private void SearchPageSongListLinkClick(object sender, RoutedEventArgs e)
        {
            SongInfoExpend cursong = ((FrameworkElement)(sender)).DataContext as SongInfoExpend;

            PlayListData PlayListData = null;

            if (cursong.Source.IndexOf("osuname_") == 0)
            {
                var f = cursong.Source.Remove(0, "osuname_".Length);
                PlayListData = MainWindow.CurMainWindowInstence.OsuData.FirstOrDefault(x => x.PlatListName == f);
            }
            else if (cursong.Source.IndexOf("netid_") == 0)
            {
                var f = cursong.Source.Remove(0, "netid_".Length);
                PlayListData = MainWindow.CurMainWindowInstence.NetCloudData.FirstOrDefault(x => {
                    if (x.PlayListId == f)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });
            }
            if (PlayListData == null)
            {
                return;
            }
            SongList.SetPlayListData(PlayListData);
            SongList.StartCmd.Enqueue("select_" + cursong.SongInfo.SongName);
            if (MainWindow.CurMainWindowInstence.frame.Source == null || MainWindow.CurMainWindowInstence.frame.Source.OriginalString != "SongList.xml")
            {
                MainWindow.CurMainWindowInstence.frame.Navigate(new Uri("SongList/SongList.xaml", UriKind.Relative));
            }
            else
            {
                MainWindow.CurMainWindowInstence.frame.Refresh();
            }
        }
Exemplo n.º 9
0
 void OnPlayingChanged(SongInfoExpend songInfoExpend)
 {
     Playing.LoadLoaclLrc(null, LrcViewOther.LrcShowWindow.CurrentInstence.Dispatcher, LrcViewOther.LrcShowWindow.CurrentInstence.LoadLrcSuccessToUI, LrcViewOther.LrcShowWindow.CurrentInstence.LoadLrcFailToUI);
     Playing.InitLrcShow(LrcViewOther.LrcShowWindow.CurrentInstence.Dispatcher);
 }
        //private CollectionView myCollectionView;

        /// <summary>
        /// 从播放列表中播放音乐
        /// </summary>
        /// <param name="NextPlay">选择当出现意外播放时的行为</param>
        static public void PlayAndExceptionPass(string NextPlay = "next")
        {
            if (PlayListIndex == 0)
            {
                return;
            }
            CurSongInfoEx = PlayListSongs[PlayListIndex - 1];
            SongInfo sinfo = CurSongInfoEx.SongInfo;

            //播放相关
            if (sinfo.SongPath == null || !File.Exists(sinfo.SongPath))
            {
                ExceptionCount++;
                if (ExceptionCount > PlayListTotal)
                {
                    MessageBox.Show("全曲目播放失败,暂停循环");
                    return;
                }
                if (NextPlay == "next" && ++PlayListIndex <= PlayListTotal)
                {
                    PlayAndExceptionPass("next");
                }
                else if (NextPlay == "prev" && --PlayListIndex >= 1)
                {
                    PlayAndExceptionPass("prev");
                }
                return;
            }
            //player.Open(sinfo.SongPath);
            //player.Play();
            //try
            //{
            //    if (player.CurrentPlayerName == "naudio")
            //        player.Open(sinfo.SongPath);
            //    else
            //    {
            //        player.Stop();
            //        player = naudioplayer;
            //        player.Open(sinfo.SongPath);
            //    }
            //}
            //catch (NotSupportedException)
            //{
            //    player = cscplayer;
            //    try
            //    {
            //        cscplayer.Open(sinfo.SongPath);
            //    }
            //    catch (Exception)
            //    {
            //        ++PlayListIndex;
            //        PlayAndExceptionPass();
            //    }
            //}
            //player.CurPlayState = PlayState.playing;
            //SendMsg(MyMsgType.Startplay, sinfo.SongPath);
            ExceptionCount = 0;
            //LRC相关
            Playing.lrcshow    = null;
            Playing.CurLrcItem = null;
            //Playing.LoadLoaclLrc(null, null, null, null);
            PlayThread = new Thread(() =>
            {
                try
                {
                    player.Open(sinfo.SongPath, ConfigPage.GlobalConfig.CurrentVolume, ConfigPage.GlobalConfig.OpenMethodsStr, ConfigPage.GlobalConfig.DeviceStr);
                    player.Play();
                }
                catch {
                    return;
                }
                PlayingChanged?.Invoke(CurSongInfoEx);

                timer.Change(1000, 1000);//这个延时大概是为了处理加载的结束;待改
            });
            PlayThread.Start();


            // Thread.Sleep(10000);
        }