Skip to content

Commit

Permalink
Stop player immediately after answering
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Klimek committed Oct 14, 2016
1 parent d5c5e0b commit 8e44724
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions MovieQuiz/Controller/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class MainController
public MainController(string jsonFile)
{
this.jsonFile = jsonFile;
player = new WMPLib.WindowsMediaPlayer();
player.PlayStateChange += OnPlayerStateChange;
}

internal void setView(Views.MainMenu view)
Expand Down Expand Up @@ -97,12 +99,6 @@ public void OnRequestHighScore()

public void OnPlaySoundFile()
{
if (player == null)
{
player = new WMPLib.WindowsMediaPlayer();
player.PlayStateChange += OnPlayerStateChange;
}

try
{
player.URL = Path.Combine(config.SoundDirectory, quiz.SoundFile);
Expand Down Expand Up @@ -147,7 +143,9 @@ public void OnTimerTick(object sender, EventArgs e)

public void OnAnswer(string answer)
{
player.controls.stop();
timer.Stop();

if (quiz.IsCorrectAnswer(answer))
{
quiz.IncreaseScore();
Expand Down

0 comments on commit 8e44724

Please sign in to comment.