aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/AudioPlayer.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-24 21:51:52 -0400
committerMichael <[email protected]>2017-04-24 21:51:52 -0400
commitd22957d2abb77f162ac5ef43a064a4ce056fc046 (patch)
treeff1cb2b143836b0b97a7a0e5dfe57a10c4a5efa4 /ShiftOS.WinForms/Applications/AudioPlayer.cs
parent99b438dd8f22fc95c7512b724618ca3e1c7af790 (diff)
downloadshiftos_thereturn-d22957d2abb77f162ac5ef43a064a4ce056fc046.tar.gz
shiftos_thereturn-d22957d2abb77f162ac5ef43a064a4ce056fc046.tar.bz2
shiftos_thereturn-d22957d2abb77f162ac5ef43a064a4ce056fc046.zip
audio player scrubbing
Diffstat (limited to 'ShiftOS.WinForms/Applications/AudioPlayer.cs')
-rw-r--r--ShiftOS.WinForms/Applications/AudioPlayer.cs52
1 files changed, 52 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.cs
index 3edf965..28e1c56 100644
--- a/ShiftOS.WinForms/Applications/AudioPlayer.cs
+++ b/ShiftOS.WinForms/Applications/AudioPlayer.cs
@@ -160,6 +160,23 @@ namespace ShiftOS.WinForms.Applications
}));
Thread.Sleep(50);
}
+ if (o.PlaybackState == NAudio.Wave.PlaybackState.Stopped)
+ {
+ if (lbtracks.SelectedIndex < lbtracks.Items.Count - 1)
+ {
+ this.Invoke(new Action(() =>
+ {
+ lbtracks.SelectedIndex++;
+ }));
+ }
+ else if(loopToolStripMenuItem.Checked == true)
+ {
+ this.Invoke(new Action(() =>
+ {
+ lbtracks.SelectedIndex = 0;
+ }));
+ }
+ }
}).Start();
}
@@ -171,6 +188,41 @@ namespace ShiftOS.WinForms.Applications
}
catch { }
}
+
+ bool scrubbing = false;
+
+ private void startScrub(object sender, MouseEventArgs e)
+ {
+ scrubbing = true;
+ }
+
+ static public double linear(double x, double x0, double x1, double y0, double y1)
+ {
+ if ((x1 - x0) == 0)
+ {
+ return (y0 + y1) / 2;
+ }
+ return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
+ }
+
+ private void pgplaytime_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (mp3 != null)
+ try
+ {
+ if (scrubbing)
+ {
+ long s_pos = (long)linear(e.X, 0, pgplaytime.Width, 0, (double)mp3.Length);
+ mp3.Position = s_pos;
+ }
+ }
+ catch { }
+ }
+
+ private void pgplaytime_MouseUp(object sender, MouseEventArgs e)
+ {
+ scrubbing = false;
+ }
}
public static class ListExtensions