mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-09 05:34:05 +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();
|
||||
soundNotification?.Dispose();
|
||||
videoPlayer?.Dispose();
|
||||
};
|
||||
|
||||
this.trayIcon.ClickRestore += trayIcon_ClickRestore;
|
||||
|
@ -6,7 +6,7 @@
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other.Management{
|
||||
sealed class VideoPlayer{
|
||||
sealed class VideoPlayer : IDisposable{
|
||||
private readonly string PlayerExe = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe");
|
||||
|
||||
public bool Running{
|
||||
@ -73,6 +73,11 @@ public void Close(){
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose(){
|
||||
ProcessExited = null;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void owner_FormClosing(object sender, FormClosingEventArgs e){
|
||||
if (currentProcess != null){
|
||||
currentProcess.Exited -= process_Exited;
|
||||
|
@ -34,9 +34,11 @@ public FormPlayer(IntPtr handle, int volume, string url){
|
||||
|
||||
Player.enableContextMenu = false;
|
||||
Player.uiMode = "none";
|
||||
Player.settings.autoStart = false;
|
||||
Player.settings.enableErrorDialogs = false;
|
||||
Player.settings.setMode("loop", true);
|
||||
|
||||
Player.MediaChange += player_MediaChange;
|
||||
|
||||
Player.PlayStateChange += player_PlayStateChange;
|
||||
Player.MediaError += player_MediaError;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private void player_MediaChange(object item){
|
||||
timerSync.Start();
|
||||
Cursor.Current = Cursors.Default;
|
||||
NativeMethods.SetWindowOwner(Handle, ownerHandle);
|
||||
Marshal.ReleaseComObject(item);
|
||||
private void player_PlayStateChange(int newState){
|
||||
WMPPlayState state = (WMPPlayState)newState;
|
||||
|
||||
if (state == WMPPlayState.wmppsReady){
|
||||
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){
|
||||
|
Loading…
Reference in New Issue
Block a user