mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-15 22:31:40 +02:00
Improve video player startup and ensure it's always closed with the main app
This commit is contained in:
@@ -117,6 +117,7 @@ namespace TweetDuck.Core{
|
|||||||
|
|
||||||
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.Controls;
|
|||||||
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 @@ namespace TweetDuck.Core.Other.Management{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 @@ namespace TweetDuck.Video{
|
|||||||
|
|
||||||
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 @@ namespace TweetDuck.Video{
|
|||||||
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){
|
||||||
|
Reference in New Issue
Block a user