mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-28 08:34:06 +02:00
Improve video player startup and ensure it's always closed with the main app
This commit is contained in:
parent
78e492c764
commit
5e9ed5d713
@ -117,6 +117,7 @@ public FormBrowser(UpdaterSettings updaterSettings){
|
|||||||
|
|
||||||
notificationScreenshotManager?.Dispose();
|
notificationScreenshotManager?.Dispose();
|
||||||
soundNotification?.Dispose();
|
soundNotification?.Dispose();
|
||||||
|
videoPlayer?.Dispose();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.trayIcon.ClickRestore += trayIcon_ClickRestore;
|
this.trayIcon.ClickRestore += trayIcon_ClickRestore;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
|
|
||||||
namespace TweetDuck.Core.Other.Management{
|
namespace TweetDuck.Core.Other.Management{
|
||||||
sealed class VideoPlayer{
|
sealed class VideoPlayer : IDisposable{
|
||||||
private readonly string PlayerExe = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe");
|
private readonly string PlayerExe = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe");
|
||||||
|
|
||||||
public bool Running{
|
public bool Running{
|
||||||
@ -73,6 +73,11 @@ public void Close(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose(){
|
||||||
|
ProcessExited = null;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
private void owner_FormClosing(object sender, FormClosingEventArgs e){
|
private void owner_FormClosing(object sender, FormClosingEventArgs e){
|
||||||
if (currentProcess != null){
|
if (currentProcess != null){
|
||||||
currentProcess.Exited -= process_Exited;
|
currentProcess.Exited -= process_Exited;
|
||||||
|
@ -34,9 +34,11 @@ public FormPlayer(IntPtr handle, int volume, string url){
|
|||||||
|
|
||||||
Player.enableContextMenu = false;
|
Player.enableContextMenu = false;
|
||||||
Player.uiMode = "none";
|
Player.uiMode = "none";
|
||||||
|
Player.settings.autoStart = false;
|
||||||
|
Player.settings.enableErrorDialogs = false;
|
||||||
Player.settings.setMode("loop", true);
|
Player.settings.setMode("loop", true);
|
||||||
|
|
||||||
Player.MediaChange += player_MediaChange;
|
Player.PlayStateChange += player_PlayStateChange;
|
||||||
Player.MediaError += player_MediaError;
|
Player.MediaError += player_MediaError;
|
||||||
|
|
||||||
trackBarVolume.Value = volume; // changes player volume too if non-default
|
trackBarVolume.Value = volume; // changes player volume too if non-default
|
||||||
@ -50,11 +52,19 @@ private void FormPlayer_Load(object sender, EventArgs e){
|
|||||||
Player.URL = videoUrl;
|
Player.URL = videoUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void player_MediaChange(object item){
|
private void player_PlayStateChange(int newState){
|
||||||
timerSync.Start();
|
WMPPlayState state = (WMPPlayState)newState;
|
||||||
Cursor.Current = Cursors.Default;
|
|
||||||
NativeMethods.SetWindowOwner(Handle, ownerHandle);
|
if (state == WMPPlayState.wmppsReady){
|
||||||
Marshal.ReleaseComObject(item);
|
Player.controls.play();
|
||||||
|
}
|
||||||
|
else if (state == WMPPlayState.wmppsPlaying){
|
||||||
|
Player.PlayStateChange -= player_PlayStateChange;
|
||||||
|
|
||||||
|
timerSync.Start();
|
||||||
|
NativeMethods.SetWindowOwner(Handle, ownerHandle);
|
||||||
|
Cursor.Current = Cursors.Default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void player_MediaError(object pMediaObject){
|
private void player_MediaError(object pMediaObject){
|
||||||
|
Loading…
Reference in New Issue
Block a user