Beispiel #1
0
        private void btnPlaySong_Click(object sender, RoutedEventArgs e)
        {
            string songpath;

            if (lbPrivate.SelectedItem != null)
            {
                timelineSlider.Value = 0;
                VisibleElements();

                for (int i = 0; i < lbPrivate.Items.Count; i++)
                {
                    if (Global.LoggedInUser.PersonalMusic[i] == lbPrivate.SelectedItem.ToString())
                    {
                        mainMediaElement.Source = null;

                        MusicOperations mo          = new MusicOperations();
                        string          selectMusic = lbPrivate.SelectedItem.ToString();
                        //string filetype = selectMusic.Remove(0, selectMusic.Length -3)
                        byte[] filesong = mo.DownloadPrivateFile(Global.LoggedInUser.PersonalMusicId[i], Global.LoggedInUser.PersonalMusicFileType[i]);
                        songpath = startupPath + selectMusic;
                        File.WriteAllBytes(songpath, filesong);


                        tbxNameSong.Text        = lbPrivate.SelectedItem.ToString();
                        mainMediaElement.Source = new Uri(songpath);
                        mainMediaElement.Play();
                    }
                }
            }
            else if (lbSong.SelectedItem != null && lbGroup.SelectedItem != null)
            {
                mainMediaElement.Source = null;

                timelineSlider.Value = 0;
                VisibleElements();

                MusicOperations mo           = new MusicOperations();
                string          namegroup    = lbGroup.SelectedItem.ToString();
                string          namesong     = lbSong.SelectedItem.ToString();
                string          fullnamesong = namegroup + " - " + namesong;
                string          idFile       = mo.GetIdFile(namegroup, namesong);
                byte[]          filesong     = mo.DownloadFile(idFile);
                songpath = startupPath + fullnamesong + ".mp3";
                File.WriteAllBytes(songpath, filesong);

                tbxNameSong.Text        = fullnamesong;
                mainMediaElement.Source = new Uri(songpath);
                mainMediaElement.Play();
            }
            else
            {
                MessageBox.Show("Choose group and song!");
            }

            lbSong.SelectedIndex    = -1;
            lbPrivate.SelectedIndex = -1;
        }
Beispiel #2
0
        public void LoadGroupBox()
        {
            MusicOperations mo    = new MusicOperations();
            var             songs = mo.DownloadGroups();

            songs = songs.Distinct().ToList();

            foreach (string song in songs)
            {
                lbGroup.Items.Add(song);
            }
        }
Beispiel #3
0
        private void btnLoadFileAdmin_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog  openFileDialog = new OpenFileDialog();
            MusicOperations mo             = new MusicOperations();

            MessageBox.Show("File should be in example format: 'Slayer - Repentless.mp3'\nPress 'Reset' after load music");
            if (openFileDialog.ShowDialog() == true)
            {
                mo.LoadFileAdmin(openFileDialog.FileName);
                MessageBox.Show("Music loaded!");
            }
        }
Beispiel #4
0
        private void lbGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selectItem;

            if (lbGroup.SelectedItem != null)
            {
                selectItem = lbGroup.SelectedItem.ToString();
                MusicOperations mo    = new MusicOperations();
                var             songs = mo.DownloadSongs(selectItem);
                songs = songs.Distinct().ToList();

                lbSong.Items.Clear();

                foreach (string song in songs)
                {
                    lbSong.Items.Add(song);
                }
            }
        }
Beispiel #5
0
        private void btnLoadFileUser_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog  openFileDialog = new OpenFileDialog();
            MusicOperations mo             = new MusicOperations();
            UsersOperations uo             = new UsersOperations();

            MessageBox.Show("File should be in example format: 'Slayer - Repentless.mp3'\nPress 'Load personal music list' after load music");

            if (openFileDialog.ShowDialog() == true)
            {
                List <string> fileData = mo.LoadFileUser(openFileDialog.FileName, Global.LoggedInUser.Id);
                string        idFile   = fileData[0];
                string        fileType = fileData[1];

                uo.LoadPrivateMusic(openFileDialog.SafeFileName, idFile, fileType);
                MessageBox.Show("Music loaded!");
            }

            //LogOut();
        }