[vlc-devel] vlc-devel Digest, Vol 52, Issue 32

sanjeev mk sanjeevmk4890 at gmail.com
Mon Sep 12 20:55:20 CEST 2011


Date: Mon, 12 Sep 2011 04:05:44 +0530

> From: sanjeev mk <sanjeevmk4890 at gmail.com>
> To: vlc-devel at videolan.org
> Subject: [vlc-devel] [PATCH] Feature addition - Automatically pause
>        when VLC is not the active window
> Message-ID:
>        <CADtxcP3qicnK1hs7DcT6RBASqZqc3ZUKkAv3Z4GU6Yp=bHEFGA at mail.gmail.com
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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.
>
> Effectively, if some other window takes up the viewer's attention (screen),
> VLC is paused, and resumed when VLC gets attention again.
>
> Thus now, video is paused in the following situations :
> 1. User minimizes VLC window (already existing feature)
> 2. User opens some other window, say Chrome or Firefox or something else
> that takes up the screen and hence the user's attention.
> 3. User goes to another window using Alt-Tab.
> 4. Unexpected pop-up window appears.
>
> Playback is resumed when VLC window becomes active again. Eg. If VLC was
> previously paused when the user had opened Chrome window, playback would
> resume when Chrome window is minimized/closed OR VLC window is explicitly
> opened again, thus making it active.
> Another example: If a pop up window appears while the user is watching a
> movie, playback would auto pause. Would be resumed when user closes/handles
> the pop up window or explicitly opens VLC window again.
>
> No need for manually pausing if the user wants to open some other window or
> task.
>
> --------------------------------------------------------------------------------------------------------------------------
>
> From: Sanjeev M K <sanjeevmk4890 at gmail.com>
> Date: Mon, 12 Sep 2011 03:26:34 +0530
> Subject: [PATCH 3/3] modified:   modules/gui/qt4/main_interface.cpp
>  Modified function changeEvent() of MainInterface to add the feature of
> auto
> pausing video playback when VLC is not currently the active window or does
> not have keyboard attention.
>
> modified:   modules/gui/qt4/main_interface.hpp
> Added variable b_hasPausedWhenInactive of type 'bool' to toggle play/pause
> when VLC window active/inactive respectively
> ---
>  modules/gui/qt4/main_interface.cpp |   23 +++++++++++++++++++++++
>  modules/gui/qt4/main_interface.hpp |    1 +
>  2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/modules/gui/qt4/main_interface.cpp
> b/modules/gui/qt4/main_interface.cpp
> index 193bf7f..1c26a03 100644
> --- a/modules/gui/qt4/main_interface.cpp
> +++ b/modules/gui/qt4/main_interface.cpp
> @@ -1145,6 +1145,29 @@ void MainInterface::changeEvent(QEvent *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;
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110912/844576f4/attachment.html
> >
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: pause_when_inactive.patch
> Type: text/x-patch
> Size: 2106 bytes
> Desc: not available
> URL: <
> http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110912/844576f4/attachment.bin
> >
>
> ------------------------------
>  ____________________________________

vlc-devel mailing list
> vlc-devel at videolan.org
> http://mailman.videolan.org/listinfo/vlc-devel
>
>
> End of vlc-devel Digest, Vol 52, Issue 32
> *****************************************
>

Sorry, the previously attached patch won't apply, it gives 'trailing
whitespace' error/warning.
Here's the patch applies cleanly (also attached as plain-text file) . The
patch implements the auto-pause when window not active feature.

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;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110913/6edc8061/attachment.html>
-------------- next part --------------
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;
 


More information about the vlc-devel mailing list