Click here to Skip to main content
15,887,975 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a project for media player with custom controls and have applied some Hotkeys using opensource SmartHotKey[^]

Now when i try to forward or backward a video i use HotKeypress event as stated on the project page of smarthotkey as follow.

this.hotKeyBackward.HotKeyPressed += new SmartHotKey.HotKey.HotKeyEventHandler(hotKeyBackword_HotKeyPressed);
this.hotKeyForward.HotKeyPressed += new SmartHotKey.HotKey.HotKeyEventHandler(hotKeyForword_HotKeyPressed);

//Registering Right & Left Keys for video forward and backword seeking
this.hotKeyBackward.AddHotKey("Left");
this.hotKeyForward.AddHotKey("Right");

//events for hotkey pressed
private void hotKeyForward_HotKeyPressed(object sender, SmartHotKey.HotKeyEventArgs e)
        {
            double position = axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
            position += 10;
            axWindowsMediaPlayer1.Ctlcontrols.currentPosition = position;                        
        }

private void hotKeyBackward_HotKeyPressed(object sender, SmartHotKey.HotKeyEventArgs e)
        {
            double position = axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
            position -= 10;
            axWindowsMediaPlayer1.Ctlcontrols.currentPosition = position;                        
        }


Now when I press hotkeys by just pressing keys normally they work fine but when i press them for little long time say for 1 sec or 2 the seekbar follow the action normally but video didn't and show photo motion effect for every 10th frame it render according to code on screen till it approach last 10th frame where keyUp event takes place

Well I know the solution that provide seeking at HotKeyDown event and get that position on HotkeyUp event like this. (if i am correct).

C#
private void hotKeyBackward_HotKeyDown(object sender, SmartHotKey.HotKeyEventArgs e)
        {
            double position = axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
            position -= 10;
        }

private void hotKeyBackward_HotKeyUp(object sender, SmartHotKey.HotKeyEventArgs e)
        {
            double position = axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
            axWindowsMediaPlayer1.Ctlcontrols.currentPosition = position;
        }


but the problem is that SmartHotkey Didn't have defination for KeyDown or Key Up events. How can i implement this? or have any other alternative. please suggest
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900