It is necessary that some method be carried out with the "A" button pressed (not pressed, namely, clamped). And when I let her go, another method was called.
There is such a code. But for some reason the melody is played for only 1 second, and then it stops.
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.A) { PlaySound(); this.MyBotton.Background = Brushes.Black; } } private void PlaySound() { wpalyer.URL = @"D:123.mp3"; wpalyer.controls.play(); } private void Window_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.A) { wpalyer.controls.stop(); this.MyBotton.Background = Brushes.White; } }
wpalyerWhat is this type? - Anton KomyshanDebug.WriteLine("что-то")) insideWindow_KeyDownand Window_KeyUp. Может быть,. Может быть,KeyDown` is called more often than you think. - VladDIsRepeat. - VladD