mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-04 17:34:07 +02:00
Rewrite key handling in video player
This commit is contained in:
parent
6357708533
commit
42f4d97d5d
@ -529,19 +529,19 @@ public void PlayVideo(string url){
|
||||
videoPlayer.Launch(url);
|
||||
}
|
||||
|
||||
public bool ToggleVideoPause(){
|
||||
public void HideVideoOverlay(){
|
||||
browser.ExecuteScriptAsync("$('#td-video-player-overlay').remove()");
|
||||
}
|
||||
|
||||
public bool ProcessBrowserKey(Keys key){
|
||||
if (videoPlayer != null && videoPlayer.Running){
|
||||
videoPlayer.TogglePause();
|
||||
videoPlayer.SendKeyEvent(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void HideVideoOverlay(){
|
||||
browser.ExecuteScriptAsync("$('#td-video-player-overlay').remove()");
|
||||
}
|
||||
|
||||
public void ShowTweetDetail(string columnKey, string chirpId){
|
||||
Activate();
|
||||
|
||||
|
@ -10,11 +10,7 @@ public KeyboardHandlerBrowser(FormBrowser form){
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut){
|
||||
if (type == KeyType.RawKeyDown && (Keys)windowsKeyCode == Keys.Space){
|
||||
return form.ToggleVideoPause();
|
||||
}
|
||||
|
||||
return false;
|
||||
return type == KeyType.RawKeyDown && form.ProcessBrowserKey((Keys)windowsKeyCode);
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey){
|
||||
|
@ -68,8 +68,8 @@ public void Launch(string url){
|
||||
}
|
||||
}
|
||||
|
||||
public void TogglePause(){
|
||||
currentPipe?.Write("pause");
|
||||
public void SendKeyEvent(Keys key){
|
||||
currentPipe?.Write("key", ((int)key).ToString());
|
||||
}
|
||||
|
||||
private void currentPipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e){
|
||||
|
@ -60,8 +60,8 @@ private void FormPlayer_Load(object sender, EventArgs e){
|
||||
|
||||
private void pipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e){
|
||||
switch(e.Key){
|
||||
case "pause":
|
||||
TogglePause();
|
||||
case "key":
|
||||
HandleKey((Keys)int.Parse(e.Data, NumberStyles.Integer));
|
||||
break;
|
||||
|
||||
case "die":
|
||||
@ -191,6 +191,17 @@ private void trackBarVolume_MouseUp(object sender, MouseEventArgs e){
|
||||
|
||||
// Controls & messages
|
||||
|
||||
private bool HandleKey(Keys key){
|
||||
switch(key){
|
||||
case Keys.Space:
|
||||
TogglePause();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePause(){
|
||||
IWMPControls controls = Player.controls;
|
||||
|
||||
@ -233,9 +244,8 @@ bool IMessageFilter.PreFilterMessage(ref Message m){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (m.Msg == 0x0100 && m.WParam.ToInt32() == 0x20){ // WM_KEYDOWN, VK_SPACE
|
||||
form.TogglePause();
|
||||
return true;
|
||||
else if (m.Msg == 0x0100){ // WM_KEYDOWN
|
||||
return form.HandleKey((Keys)m.WParam.ToInt32());
|
||||
}
|
||||
else if (m.Msg == 0x020B && ((m.WParam.ToInt32() >> 16) & 0xFFFF) == 1){ // WM_XBUTTONDOWN
|
||||
NativeMethods.SetForegroundWindow(form.ownerHandle);
|
||||
|
Loading…
Reference in New Issue
Block a user