Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Implemented SetMouseInput and SetKeyInput #424

Closed
wants to merge 5 commits into from

Conversation

CrookedFingerGuy
Copy link

New to the project I hope I put stuff in the right spot. Feel free to tell me what I did wrong.

I implemented the delegates for libvlc_video_set_mouse_input and libvlc_video_set_key_input. These values are true by default in libvlc. I chose to make them default to false for the vlcControl.

I also left in the changes I made to the WinForms.Advanced Sample that I used for testing.

libvlc implements these functions in a non-intuitive way. They only take effect when the next video plays. Also, for mouse inputs to work BOTH libvlc_video_set_mouse_input and libvlc_video_set_key_input have to be set to false.

I implemented the delegates for libvlc_video_set_mouse_input and libvlc_video_set_key_input. These values are true by default in libvlc. I chose to make them default to false for the vlcControl.

libvlc implements these functions in a non-intuitive way. They only take effect when the next video plays. Also, for mouse inputs to work BOTH  libvlc_video_set_mouse_input and libvlc_video_set_key_input have to be set to false.
@jeremyVignelles
Copy link
Collaborator

Thanks a lot for that, I will need to have a look at this, don't hesitate to ping me in a few days if I forget (quite busy right now)

I'm not sure if we should change the default however. If libvlc sets this to false, so should we. There should be a reason...

Changed the default values for libvlc_video_set_mouse_input and libvlc_video_set_ky_input to true.

I also updated the WinForms.Advanced sample to reflect the change.
Copy link
Collaborator

@jeremyVignelles jeremyVignelles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry for taking that long. Could you please see my remarks and come back with an updated version?
I really appreciate your help!

@@ -46,5 +48,15 @@ public string Deinterlace
public IMarqueeManagement Marquee { get; private set; }
public ILogoManagement Logo { get; private set; }
public IAdjustmentsManagement Adjustments { get; private set; }

public bool IsMouseInputDisabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer "positive" naming here, and everywhere else. Please use IsMouseInputEnabled and IsKeyInputEnabled (This avoids double negation confusion)

{
public sealed partial class VlcManager
{
public void SetKeyInput(VlcMediaPlayerInstance mediaPlayerInstance, bool status)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename "status" to "enabled" or "on" (to make it on par with vlc's naming)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experiments, those methods have no effect once the video has started playing. Do you think we should make that clear? (A comment above saying : "Must be called before the stream has started playing"). What do you think about that?

{
if (mediaPlayerInstance == IntPtr.Zero)
throw new ArgumentException("Media player instance is not initialized.");
GetInteropDelegate<SetKeyInput>().Invoke(mediaPlayerInstance, Convert.ToUInt32(status ? 1 : 0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use 1u / 0u to avoid the conversion

{
public sealed partial class VlcManager
{
public void SetMouseInput(VlcMediaPlayerInstance mediaPlayerInstance, bool status)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments apply here


public bool IsMouseInputDisabled
{
set { myManager.SetMouseInput(myMediaPlayer, value); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the logic here. If "disabled" is true, then "state" in SetMouseInput is true and 1 is passed, which means on. Unless I'm missing something, that logic is broken, but will be OK once you have performed the renaming above.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that "enabled" means "enable handling by libvlc"

@@ -16,6 +16,8 @@ public VideoManagement(VlcManager manager, VlcMediaPlayerInstance mediaPlayerIns
Marquee = new MarqueeManagement(manager, mediaPlayerInstance);
Logo = new LogoManagement(manager, mediaPlayerInstance);
Adjustments = new AdjustmentsManagement(manager, mediaPlayerInstance);
IsMouseInputDisabled = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the initialization, it's the default

…cation to the perspective of the libvlc.

Switched the Enable/Disabled naming from the perspective of the application to the perspective of the libvlc.
@CrookedFingerGuy
Copy link
Author

I have no strong opinions about any of the changes you requested. I think I have made all of the changes you have requested. Thanks for being very specific about the changes you wanted.

Have a nice day.

Oops looks Like a I missed a small problem with references.
@CrookedFingerGuy
Copy link
Author

I'm not sure how to resolve this errors here. I don't want to mess up your repository so I am going to just close this pull request. Sorry to have wasted your time on this one.

@CrookedFingerGuy
Copy link
Author

Ok, I have reverted that change to the references. I'm going to try and reopen this pull request.

@jeremyVignelles
Copy link
Collaborator

Otherwise that's fine, thanks for your PR

@jeremyVignelles
Copy link
Collaborator

I forgot : could you also update the changelog.md with a link to this PR?

@jeremyVignelles
Copy link
Collaborator

I merged this manually, thanks for your contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants