private void PlayNext(PlayerActions action) { if (action == PlayerActions.RandomPlay) { int randomIndex = rnd.Next(0, Client.FileList.Length); while (randomIndex == selectedMusicIndex) { randomIndex = rnd.Next(0, Client.FileList.Length); } selectedMusicIndex = randomIndex; } else if (action == PlayerActions.RePlay) { BassCore.Play(Client.FileList[selectedMusicIndex], volume_bar.Value); return; } else { if (Client.FileList.Length > (selectedMusicIndex + 1)) { selectedMusicIndex += 1; } else if (Client.FileList.Length == 1) { BassCore.Play(Client.FileList[selectedMusicIndex], volume_bar.Value); } else if (selectedMusicIndex == (Client.FileList.Length - 1)) { selectedMusicIndex = 0; } } BassCore.Play(Client.FileList[selectedMusicIndex], volume_bar.Value); prevSelectedMusicIndex = selectedMusicIndex; PlayerSet(); }
private void Left_arrow_btn_MouseDown(object sender, MouseEventArgs e) { if (music_Track_Bar.Value - 5 <= 0) { BassCore.SetChannelPosition(BassCore.Stream, 0); } else { BassCore.SetChannelPosition(BassCore.Stream, music_Track_Bar.Value -= 5); } }
private void PlayerSet() { playing = true; newPlaying = false; music_progress_time.Show(); music_progress_total_time.Show(); music_Track_Bar.Maximum = BassCore.GetLengthOfStream(BassCore.Stream); music_progress_total_time.Text = TimeSpan.FromSeconds(BassCore.GetLengthOfStream(BassCore.Stream)).ToString(); play_btn.MouseEnter -= Play_btn_MouseEnter; play_btn.MouseLeave -= Play_btn_MouseLeave; play_btn.MouseEnter += Pause_btn_MouseEnter; play_btn.MouseLeave += Pause_btn_MouseLeave; player_refresher.Start(); }
private async void login_btn_Click(object sender, EventArgs e) { music_list.Hide(); if (!account.IsAuthorized) { BassCore.Stop(); PlayerDefaultSet(true); play_btn.Image = Properties.Resources.play_gray; using (var stream = new FileStream(Properties.Resources.UserDataJSONPath, FileMode.Open)) { using (var stream2 = new FileStream(Properties.Resources.SecretUserJSONDataPath, FileMode.Open)) { using (var reader = new StreamReader(stream)) { UserDataJSON = reader.ReadToEnd(); if (string.IsNullOrEmpty(UserDataJSON)) { var form = new Sign_in_form(this); form.Show(); this.Hide(); form.BringToFront(); } else { LoadBar bar = new LoadBar(); this.Hide(); bar.Show(); SecretUserJSON = new StreamReader(stream2).ReadToEnd(); Client = new VKManager(); Task t = new Task(() => { account = Client.AuthentificateFromFile(UserDataJSON, SecretUserJSON); }); t.Start(); await t; this.Show(); RefreshLoginPanel(); bar.Close(); } } } } } if (account.IsAuthorized && closed) { login_btn.Location = new Point(0, 0); userPicture.Location = new Point(5, 0); } Refresh(); }
private void Volume_btn_Click(object sender, EventArgs e) { if (flg) { volume_bar.Value = 0; flg = false; volume_btn.Image = Properties.Resources.volume_white_no; } else { volume_bar.Value = 100; flg = true; volume_btn.Image = Properties.Resources.volume_white_max; } volume_btn.Refresh(); BassCore.SetVolumeToStream(BassCore.Stream, volume_bar.Value); }
private void Player_refresher_Tick(object sender, EventArgs e) { if (playing) { music_progress_time.Text = TimeSpan.FromSeconds(BassCore.GetStreamPosition(BassCore.Stream)).ToString(); music_Track_Bar.Value = BassCore.GetStreamPosition(BassCore.Stream); if (music_progress_time.Text == music_progress_total_time.Text) { BassCore.Stop(); PlayNext(action); } } else { BassCore.Stop(); PlayerDefaultSet(true); } }
private void Play(object sender) { if (!playing) { if (selectedMusicIndex == -1) { music_Track_Bar.Enabled = false; volume_bar.Enabled = false; volume_btn.Enabled = false; return; } ((Button)sender).Image = Properties.Resources.pause_white; if (Client == null) { Client = new VKManager(); } if (newPlaying) { BassCore.Play(Client.FileList[selectedMusicIndex], BassCore.Volume); } else { BassCore.Continue(BassCore.Stream); } PlayerSet(); } else { ((Button)sender).Image = Properties.Resources.play_white; if (selectedMusicIndex == prevSelectedMusicIndex) { BassCore.Pause(); PlayerDefaultSet(false); } else if (selectedMusicIndex != prevSelectedMusicIndex) { BassCore.Stop(); PlayerDefaultSet(true); } } ((Button)sender).Refresh(); prevSelectedMusicIndex = selectedMusicIndex; }
private void logout_btn_Click(object sender, EventArgs e) { if (playing) { BassCore.Stop(); PlayerDefaultSet(true); } music_list.Hide(); music_list.Controls.Clear(); login_btn.Location = new Point(12, 0); userPicture.Location = new Point(12, 0); account = new VKAccount(); Client = null; login_btn.Text = "Sign In"; login_btn.Image = Properties.Resources.login_32; userPicture.Visible = false; Refresh(); logout_btn.Enabled = false; logout_btn.Visible = false; light_panel.Location = new Point(3, 0); title_btn_general.Text = new string(' ', 4) + login_btn.Text; }
private void Volium_bar_Scroll(object sender, EventArgs e) { BassCore.SetVolumeToStream(BassCore.Stream, volume_bar.Value); ToVolGray(); volume_btn.Refresh(); }
private void Music_Track_Bar_Scroll(object sender, ScrollEventArgs e) { BassCore.SetChannelPosition(BassCore.Stream, music_Track_Bar.Value); }
private void Right_arrow_btn_MouseDown(object sender, MouseEventArgs e) { BassCore.SetChannelPosition(BassCore.Stream, music_Track_Bar.Value += 5); }