mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-25 08:34:05 +02:00
Cleanup FormPlayer code and set sync timer interval to 15 instead of 10
This commit is contained in:
parent
03af6cecaa
commit
40ca923745
video/TweetDuck.Video
2
video/TweetDuck.Video/FormPlayer.Designer.cs
generated
2
video/TweetDuck.Video/FormPlayer.Designer.cs
generated
@ -36,7 +36,7 @@ private void InitializeComponent() {
|
|||||||
//
|
//
|
||||||
// timerSync
|
// timerSync
|
||||||
//
|
//
|
||||||
this.timerSync.Interval = 10;
|
this.timerSync.Interval = 15;
|
||||||
this.timerSync.Tick += new System.EventHandler(this.timerSync_Tick);
|
this.timerSync.Tick += new System.EventHandler(this.timerSync_Tick);
|
||||||
//
|
//
|
||||||
// trackBarVolume
|
// trackBarVolume
|
||||||
|
@ -68,7 +68,9 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
if (NativeMethods.GetWindowRect(ownerHandle, out NativeMethods.RECT rect)){
|
if (NativeMethods.GetWindowRect(ownerHandle, out NativeMethods.RECT rect)){
|
||||||
int width = rect.Right-rect.Left+1;
|
int width = rect.Right-rect.Left+1;
|
||||||
int height = rect.Bottom-rect.Top+1;
|
int height = rect.Bottom-rect.Top+1;
|
||||||
|
|
||||||
IWMPMedia media = Player.currentMedia;
|
IWMPMedia media = Player.currentMedia;
|
||||||
|
IWMPControls controls = Player.controls;
|
||||||
|
|
||||||
bool isCursorInside = ClientRectangle.Contains(PointToClient(Cursor.Position));
|
bool isCursorInside = ClientRectangle.Contains(PointToClient(Cursor.Position));
|
||||||
|
|
||||||
@ -78,9 +80,9 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
tablePanel.Visible = isCursorInside || isDragging;
|
tablePanel.Visible = isCursorInside || isDragging;
|
||||||
|
|
||||||
if (tablePanel.Visible){
|
if (tablePanel.Visible){
|
||||||
labelTime.Text = $"{Player.controls.currentPositionString} / {Player.currentMedia.durationString}";
|
labelTime.Text = $"{controls.currentPositionString} / {media.durationString}";
|
||||||
|
|
||||||
int value = (int)Math.Round(progressSeek.Maximum*Player.controls.currentPosition/Player.currentMedia.duration);
|
int value = (int)Math.Round(progressSeek.Maximum*controls.currentPosition/media.duration);
|
||||||
|
|
||||||
if (value >= progressSeek.Maximum){
|
if (value >= progressSeek.Maximum){
|
||||||
progressSeek.Value = progressSeek.Maximum;
|
progressSeek.Value = progressSeek.Maximum;
|
||||||
@ -93,10 +95,10 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Player.controls.currentPosition > Player.currentMedia.duration){ // pausing near the end of the video causes WMP to play beyond the end of the video wtf
|
if (controls.currentPosition > media.duration){ // pausing near the end of the video causes WMP to play beyond the end of the video wtf
|
||||||
Player.controls.stop();
|
controls.stop();
|
||||||
Player.controls.currentPosition = 0;
|
controls.currentPosition = 0;
|
||||||
Player.controls.play();
|
controls.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCursorInside && !wasCursorInside){
|
if (isCursorInside && !wasCursorInside){
|
||||||
@ -109,6 +111,9 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
NativeMethods.SetForegroundWindow(ownerHandle);
|
NativeMethods.SetForegroundWindow(ownerHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Marshal.ReleaseComObject(media);
|
||||||
|
Marshal.ReleaseComObject(controls);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Environment.Exit(Program.CODE_OWNER_GONE);
|
Environment.Exit(Program.CODE_OWNER_GONE);
|
||||||
@ -122,12 +127,21 @@ private void timerData_Tick(object sender, EventArgs e){
|
|||||||
|
|
||||||
private void progressSeek_MouseDown(object sender, MouseEventArgs e){
|
private void progressSeek_MouseDown(object sender, MouseEventArgs e){
|
||||||
if (e.Button == MouseButtons.Left){
|
if (e.Button == MouseButtons.Left){
|
||||||
Player.controls.currentPosition = Player.currentMedia.duration*progressSeek.PointToClient(Cursor.Position).X/progressSeek.Width;
|
IWMPMedia media = Player.currentMedia;
|
||||||
|
IWMPControls controls = Player.controls;
|
||||||
|
|
||||||
|
controls.currentPosition = media.duration*progressSeek.PointToClient(Cursor.Position).X/progressSeek.Width;
|
||||||
|
|
||||||
|
Marshal.ReleaseComObject(media);
|
||||||
|
Marshal.ReleaseComObject(controls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trackBarVolume_ValueChanged(object sender, EventArgs e){
|
private void trackBarVolume_ValueChanged(object sender, EventArgs e){
|
||||||
Player.settings.volume = trackBarVolume.Value;
|
IWMPSettings settings = Player.settings;
|
||||||
|
settings.volume = trackBarVolume.Value;
|
||||||
|
|
||||||
|
Marshal.ReleaseComObject(settings);
|
||||||
|
|
||||||
if (timerSync.Enabled){
|
if (timerSync.Enabled){
|
||||||
timerData.Stop();
|
timerData.Stop();
|
||||||
@ -146,14 +160,17 @@ private void trackBarVolume_MouseUp(object sender, MouseEventArgs e){
|
|||||||
// Controls & messages
|
// Controls & messages
|
||||||
|
|
||||||
private void TogglePause(){
|
private void TogglePause(){
|
||||||
|
IWMPControls controls = Player.controls;
|
||||||
|
|
||||||
if (isPaused){
|
if (isPaused){
|
||||||
Player.controls.play();
|
controls.play();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Player.controls.pause();
|
controls.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
isPaused = !isPaused;
|
isPaused = !isPaused;
|
||||||
|
Marshal.ReleaseComObject(controls);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class MessageFilter : IMessageFilter{
|
internal class MessageFilter : IMessageFilter{
|
||||||
|
Loading…
Reference in New Issue
Block a user