[vlc-devel] [PATCH] Feature addition - Automatically pause when VLC is not the active window

sanjeev mk sanjeevmk4890 at gmail.com
Tue Sep 13 11:38:08 CEST 2011


Okay, if not many users want it, no problem :).  Many of us (me and my
colleagues) have found the need for auto-pause, especially when we change
windows using Alt+Tab, or open a browser, or situations like that. When I
open my browser to quickly check my mail, the video keeps running in the
background, so I then go back and manually pause it. And we already have the
pause-when-minimized option, so I decided to extend it by adding this
feature of pausing when the user not actually watching the video playback .
 And playback is resumed when the user is again watching the video. So, I
figured may be many others might use it, hence the patch.

Anyway, for those who want this feature or just want to see how it works,
use this patch, the one I posted earlier gives white space errors. A clean
patch:

Author: Sanjeev M K <sanjeevmk4890 at gmail.com>   IRC Nick : s-mk

diff --git a/modules/gui/qt4/main_interface.cpp
b/modules/gui/qt4/main_interface.cpp
index 193bf7f..f3bb2aa 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1145,7 +1145,29 @@ void MainInterface::changeEvent(QEvent *event)
         }
     }

-    QWidget::changeEvent(event);
+ else if( (event->type() == QEvent::ActivationChange) )
+ {
+ if( THEMIM->getIM()->playingStatus() == PLAYING_S &&
+ THEMIM->getIM()->hasVideo() &&
+ !THEMIM->getIM()->hasVisualisation() &&
+ var_InheritBool( p_intf, "qt-pause-minimized" ) )
+ {
+ b_hasPausedWhenInactive=true;
+ THEMIM->pause();
+ }
+ else if(THEMIM->getIM()->playingStatus() == PAUSE_S &&
+ THEMIM->getIM()->hasVideo() &&
+ !THEMIM->getIM()->hasVisualisation() &&
+ var_InheritBool( p_intf, "qt-pause-minimized" ) )
+ {
+ if(b_hasPausedWhenInactive)
+ {
+ b_hasPausedWhenInactive=false;
+ THEMIM->play();
+ }
+ }
+
+ QWidget::changeEvent(event);
 }

 /************************************************************************
diff --git a/modules/gui/qt4/main_interface.hpp
b/modules/gui/qt4/main_interface.hpp
index cfac21f..dfd0935 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -168,6 +168,7 @@ private:
 //    bool                 b_visualSelectorEnabled;
     bool                 b_plDocked;            ///< Is the playlist docked
?

+ bool b_hasPausedWhenInactive;
     bool                 b_hasPausedWhenMinimized;
     bool                 b_statusbarVisible;


On Tue, Sep 13, 2011 at 1:12 PM, Kaarlo Räihä <kaarlo.raiha at gmail.com>wrote:

>
>
> 2011/9/13 Jean-Paul Saman <jpsaman at gmail.com>
>
>> 2011/9/13 Rémi Denis-Courmont <remi at remlab.net>:
>> >   Hello,
>> >
>> > On Monday 12 September 2011, sanjeev mk wrote:
>> >> This patch is a feature addition/request.
>> >> Currently, if the user minimizes VLC , video playback is auto paused
>> and it
>> >> is resumed when the user 'un'minimizes VLC again.
>> >>
>> >> The following patch (also attached) adds to the existing feature by
>> >> implementing auto pause of video when VLC Player window is not active
>> or
>> >> does not have keyboard attention. The playback is resumed when VLC
>> Player
>> >> becomes the active window again.
>> >
>> > As a user, I definitely do NOT want this "feature"...
>>
>> I agree.
>>
>
> Some people have requested something like this on forums. But maybe the
> upcoming boss-key feature is more what they want.
>
>


>> Kind regards,
>> Jean-Paul Saman
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> http://mailman.videolan.org/listinfo/vlc-devel
>>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>
>


-- 
Regards,
Sanjeev M K
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110913/9c1335f3/attachment.html>


More information about the vlc-devel mailing list