Page 1 of 1

[Extension] Click screen to PAUSE / PLAY

Posted: 02 Feb 2013 15:29
by mederi

Code: Select all

-- "click screen to pause.lua" -- VLC2.0.x Extension script function descriptor() return { title = "Click screen to PAUSE / PLAY" } end function activate() vlc.var.add_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end function deactivate() vlc.var.del_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end function mouse_press( var, old, new, data ) vlc.msg.info("[Click screen to PAUSE / PLAY] var: "..tostring(var).." / old: "..tostring(old).." / new: "..tostring(new)) if old==0 and new==1 then vlc.playlist.pause() end end
If you need some installation insctructions, then you can find them for example here: http://addons.videolan.org/content/show ... ent=156396

I think that it works quite well and with possible VLC ability of automatic start of extensions it would be just great. It is optional and easy to enable/disable it from VLC menu: View > Click screen to PAUSE / PLAY

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 03 Apr 2013 16:53
by mbaker72
Great Plugin! Thank you, just what I've been looking for!

Is there a way to activate the Plugin by default so that it is activated every time I launch VLC - instead of activating it via "View/Enable"?

Kind regards!

//MB

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 03 Apr 2013 21:44
by mederi
Auto-load of extensions is possible but not implemented yet.
Ticket #3883
Auto-load support for Lua extensions
http://trac.videolan.org/vlc/ticket/3883
This extension is not complete yet (if no vout object, if play another input), but it works and everybody can test behaviour and interaction with other features in VLC. Perhaps later this feature could be implemented in VLC by some willing developer.

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 08 Apr 2013 23:13
by snark.real
This is very nice idea! Grats!
I've fixed and extended this plugin a little bit.
Now you need to turn it on only once. And yes, autostarting of addons would be very handy.

Code: Select all

-- "clickpause.lua" -- VLC2.0.x Extension script DEBUG = false function descriptor() return { title = "Click screen to PAUSE / PLAY"; capabilities = { "input-listener" }; } end function d_log(...) local out = "" if not DEBUG then return end for i,v in ipairs(arg) do out = out .. " " .. v end vlc.msg.info(out) end function activate() if vlc.object.input() then vlc.var.add_callback( vlc.object.vout(), "mouse-button-down", mouse_press) no_input = false else no_input = true end end function deactivate() if vlc.object.input() then vlc.var.del_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end end function mouse_press( var, old, new, data ) d_log("[Click screen to PAUSE / PLAY] var: "..tostring(var).." / old: "..tostring(old).." / new: "..tostring(new)) if old==0 and new==1 then vlc.playlist.pause() end end function input_changed() no_input = not not vlc.object.input() d_log("input changed", "no_input " .. tostring(no_input)) end function meta_changed() d_log("meta changed " .. " no_input " .. tostring(no_input) .. " input " .. tostring(not not vlc.object.input())) if no_input and not not vlc.object.input() then vlc.var.add_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end no_input = false end

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 09 Apr 2013 23:18
by mederi
This way the extension pauses video only in every other playlist item for me.

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 10 Apr 2013 02:26
by snark.real
This way the extension pauses video only in every other playlist item for me.
Yeap, that was a bug. I haven't tested it with playlists, because I don't use them.
Fix is small, but I'll post it again, because I can not edit previous post

Code: Select all

-- "clickpause.lua" -- VLC2.0.x Extension script DEBUG = false function descriptor() return { title = "Click screen to PAUSE / PLAY"; capabilities = { "input-listener" }; } end function d_log(...) local out = "" if not DEBUG then return end for i,v in ipairs(arg) do out = out .. " " .. v end vlc.msg.info(out) end function activate() if vlc.object.input() then vlc.var.add_callback( vlc.object.vout(), "mouse-button-down", mouse_press) no_input = false else no_input = true end end function deactivate() if vlc.object.input() then pcall(vlc.var.del_callback, vlc.object.vout(), "mouse-button-down", mouse_press) end end function mouse_press( var, old, new, data ) d_log("[Click screen to PAUSE / PLAY] var: "..tostring(var).." / old: "..tostring(old).." / new: "..tostring(new)) if old==0 and new==1 then vlc.playlist.pause() end end function input_changed() no_input = not not vlc.object.input() d_log("input changed", "no_input " .. tostring(no_input)) end function meta_changed() d_log("meta changed " .. " no_input " .. tostring(no_input) .. " input " .. tostring(not not vlc.object.input())) if no_input and not not vlc.object.input() then pcall(vlc.var.del_callback, vlc.object.vout(), "mouse-button-down", mouse_press) vlc.var.add_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end no_input = false end
BTW, meredi, do you care if I put this code somewhere, (under MIT license, for example) and mention you in credits?
Because forum is not a VCS :)

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 10 Apr 2013 14:38
by mederi
Thank you. Now the extension is ready for publishing on http://addons.videolan.org Please do it.

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 19 Apr 2013 14:02
by snark.real

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 02 Oct 2013 16:53
by One second
thanks
this plugin is very nice
by the way
i little changed code to not pause when i doubleclick
to become fullscreen.
goodbye:)

Code: Select all

function mouse_press( var, old, new, data ) if old==0 and new==1 then time1=os.clock() end if old==1 and new==0 then if os.clock()-time1 > 0.07 then vlc.playlist.pause() end --vlc.msg.info(os.clock()-time1) end end

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 09 Mar 2014 01:32
by mg2
Not working on 2.1.3 :( Any suggestions?

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 14 Mar 2014 16:30
by mederi
It works with VLC-2.0.x
Here is the related ticket for somebody able/willing to restore the function:
Ticket #8097: Lua Extensions, VLC2.1: var.add_callback( ), var.del_callback( ) do not work

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 31 Mar 2014 07:18
by zzzk
PLEASE add this function back! To me, this function should be default! Also resume option for videos should be default! Or at least allow add-ons to do this function. I can't find one for the 2.1 version. Thank you. :( :( :( :(

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 18 Jun 2014 09:30
by talismancer
bump...this should be VLC's default behaviour (along with auto-loading extensions)

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 31 Jul 2014 07:24
by vstar
This function should be default or included in the settings with vlc player. I am looking for this function too.

Re: VLC Extension: Click screen to PAUSE / PLAY

Posted: 08 Sep 2014 13:08
by snark.real
I know, guys, that you like this extension. So do I. But things changed.
The problem with extension is that callbacks were removed because they were supposedly causing unstable behavior of VLC.
I don't feel like I can judge Jean-Baptist for removing callbacks from lua api from VLC2.0.1, because he is leading this project successfully for too long, he know it's ins and outs a lot better than I do. But I were him, I wouldn't break API before "proper implementation" will arise.
What are our options now?
* Find a c++ developer wiling to fix Ticket #8097 and raise donations for paying for his work. This could be a long-term investment and improve extension API a lot once and forever. (Lua API needs proper support for threads, timers and other multi-tasking stuff).
* Try to convince Jean-Baptist to add callbacks back with little to no success and continue whining on.
* Try to do something yourself.
There is a great quote by mederi:
If you find this forum and this thread, you have enough information here to start writing your own scripts. All you need is "README.txt", Lua manual and some programming skills. Then you have described structure of extension and playlist scripts here, example scripts all around, ideas and problems discussed on the forum here. All useful links are provided. How would you like to start without reading and learning?

However, there are still some secrets waiting to be discovered. The problem is that the original VLC Lua hobbyist developer left the project a few years ago and never "finished" the Lua support. So all we can do is to support each other and VLC developers working on this open source project in their free time.
So if you really feel for this feature, raise your voice, and together we can change VLC for the better!

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 10 Sep 2016 20:22
by VLmurphy
From what I read above, is it correct to say that you don't even have to bother trying out the extensions posted here, because they won't work anymore with current VLC versions anyway?

I originally followed the discussion in this (9-year-old) thread and took it further there.

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 18 Oct 2016 09:18
by jgt1942

Code: Select all

-- "click screen to pause.lua" -- VLC2.0.x Extension script function descriptor() return { title = "Click screen to PAUSE / PLAY" } end function activate() vlc.var.add_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end function deactivate() vlc.var.del_callback( vlc.object.vout(), "mouse-button-down", mouse_press) end function mouse_press( var, old, new, data ) vlc.msg.info("[Click screen to PAUSE / PLAY] var: "..tostring(var).." / old: "..tostring(old).." / new: "..tostring(new)) if old==0 and new==1 then vlc.playlist.pause() end end
If you need some installation insctructions, then you can find them for example here: http://addons.videolan.org/content/show ... ent=156396

I think that it works quite well and with possible VLC ability of automatic start of extensions it would be just great. It is optional and easy to enable/disable it from VLC menu: View > Click screen to PAUSE / PLAY
OK I'm totally lost regarding the installation. I clicked on the suggest link and the page that opens is about "Jump to time (Previous frame) v2.1". In this thread I see the option to copy the code to the clipboard and this I can do but then I'm lost.

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 18 Oct 2016 09:27
by jgt1942
OK I think I got it installed but it is not working. What the heck?????

Forgot to mention I'm running VCL 2.2.4 on Win10 x64

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 18 Oct 2016 19:04
by VLmurphy
How about reading my post DIRECTLY above yours? -_-

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 28 Oct 2016 06:02
by jgt1942
How about reading my post DIRECTLY above yours? -_-
Ops, for whatever reason I did not previously see it. Now that I see it, I agree with you. It would be nice if the developers added this support. But I guess that userfriendly is not a key thought process.

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 28 Oct 2016 06:10
by VLmurphy
Now that I see it, I agree with you. It would be nice if the developers added this support. But I guess that userfriendly is not a key thought process.
You nailed it ;) This has been a continuous struggle for years, then there were the plugins, then they didn't work anymore because of general restrictions, and then ... nothing. To pretend it never happened seems to be the current strategy.

There have always been "reasons", but no one actually ever understood why it really can't be implemented, despite frequent requests :)

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 30 Oct 2016 16:46
by RĂ©mi Denis-Courmont
How about reading my post DIRECTLY above yours? -_-
Ops, for whatever reason I did not previously see it. Now that I see it, I agree with you. It would be nice if the developers added this support. But I guess that userfriendly is not a key thought process.
I must say that I do not see the link between the Lua add_callback and del_callback functions and user friendliness. Writing, or even just installing external Lua scripts is anything but what I would consider user firendly, regardless of the callback functions.

And indeed, unfortunately, user friendliness is not exactly the top priority, nor is UI development in general. On the one hand, you have paid developers; for the most part, they care either about VLC as a headless streaming toolkit, as an embbedable playback software library, or as a mobile application. On the other hand, you have the hobbyist (me included) who have way too little free time to improve the user interface, and typically are interested in multimedia technology, not user experience.

The desktop UI has tens of millions of users, but nobody really caring for it to the extent that they'd be willing and able to dedicate enough time or money to it.

Re: [Extension] Click screen to PAUSE / PLAY

Posted: 30 Oct 2016 20:33
by VLmurphy
Thanks for your enlightening clarifications, also in the other thread. Very much appreciated.