Skip to content

Commit

Permalink
Fix for audio only starting the first time around.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner committed Nov 27, 2017
1 parent 582b0a4 commit ff1348f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Control/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ private void EvalOptions()
// Store the current sequence
int temp = _currentSequence;

// Before we can try to set the next media node, we need to stop any currently running Audio
StopAudio();

// Set the next media node for this panel
if (!SetNextMediaNodeInOptions())
{
Expand Down Expand Up @@ -662,7 +665,7 @@ void audio_DurationElapsedEvent(int filesPlayed)
{
try
{
StopMedia(_options.Audio[_audioSequence - 1], true);
StopMedia(_options.Audio[_audioSequence - 1]);
}
catch (Exception ex)
{
Expand All @@ -678,14 +681,6 @@ void audio_DurationElapsedEvent(int filesPlayed)
/// </summary>
/// <param name="media"></param>
private void StopMedia(Media media)
{
StopMedia(media, false);
}

/// <summary>
/// Stop the provided media
/// </summary>
private void StopMedia(Media media, bool audio)
{
Trace.WriteLine(new LogMessage("Region - Stop Media", "Stopping media"), LogType.Audit.ToString());

Expand All @@ -705,13 +700,19 @@ private void StopMedia(Media media, bool audio)
{
Trace.WriteLine(new LogMessage("Region - Stop Media", "Unable to dispose. Ex = " + ex.Message), LogType.Audit.ToString());
}
}

// Stop any associated audio
if (!audio && _options.Audio.Count >= _audioSequence)
/// <summary>
/// Stop Audio
/// </summary>
private void StopAudio()
{
// Stop the currently playing audio (if there is any)
if (_options.Audio.Count > 0)
{
try
{
StopMedia(_options.Audio[_audioSequence - 1], true);
StopMedia(_options.Audio[_audioSequence - 1]);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -794,6 +795,9 @@ public void Clear()
{
try
{
// Stop Audio
StopAudio();

// Stop the current media item
if (_media != null)
StopMedia(_media);
Expand Down

0 comments on commit ff1348f

Please sign in to comment.