<br>Date: Mon, 12 Sep 2011 04:05:44 +0530<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: sanjeev mk <<a href="mailto:sanjeevmk4890@gmail.com" target="_blank">sanjeevmk4890@gmail.com</a>><br>
To: <a href="mailto:vlc-devel@videolan.org" target="_blank">vlc-devel@videolan.org</a><br>
Subject: [vlc-devel] [PATCH] Feature addition - Automatically pause<br>
        when VLC is not the active window<br>
Message-ID:<br>
        <CADtxcP3qicnK1hs7DcT6RBASqZqc3ZUKkAv3Z4GU6Yp=<a href="mailto:bHEFGA@mail.gmail.com" target="_blank">bHEFGA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
This patch is a feature addition/request.<br>
Currently, if the user minimizes VLC , video playback is auto paused and it<br>
is resumed when the user 'un'minimizes VLC again.<br>
<br>
The following patch (also attached) adds to the existing feature by<br>
implementing auto pause of video when VLC Player window is not active or<br>
does not have keyboard attention. The playback is resumed when VLC Player<br>
becomes the active window again.<br>
<br>
Effectively, if some other window takes up the viewer's attention (screen),<br>
VLC is paused, and resumed when VLC gets attention again.<br>
<br>
Thus now, video is paused in the following situations :<br>
1. User minimizes VLC window (already existing feature)<br>
2. User opens some other window, say Chrome or Firefox or something else<br>
that takes up the screen and hence the user's attention.<br>
3. User goes to another window using Alt-Tab.<br>
4. Unexpected pop-up window appears.<br>
<br>
Playback is resumed when VLC window becomes active again. Eg. If VLC was<br>
previously paused when the user had opened Chrome window, playback would<br>
resume when Chrome window is minimized/closed OR VLC window is explicitly<br>
opened again, thus making it active.<br>
Another example: If a pop up window appears while the user is watching a<br>
movie, playback would auto pause. Would be resumed when user closes/handles<br>
the pop up window or explicitly opens VLC window again.<br>
<br>
No need for manually pausing if the user wants to open some other window or<br>
task.<br>
--------------------------------------------------------------------------------------------------------------------------<br>
<br>
From: Sanjeev M K <<a href="mailto:sanjeevmk4890@gmail.com" target="_blank">sanjeevmk4890@gmail.com</a>><br>
Date: Mon, 12 Sep 2011 03:26:34 +0530<br>
Subject: [PATCH 3/3] modified:   modules/gui/qt4/main_interface.cpp<br>
 Modified function changeEvent() of MainInterface to add the feature of auto<br>
pausing video playback when VLC is not currently the active window or does<br>
not have keyboard attention.<br>
<br>
modified:   modules/gui/qt4/main_interface.hpp<br>
Added variable b_hasPausedWhenInactive of type 'bool' to toggle play/pause<br>
when VLC window active/inactive respectively<br>
---<br>
 modules/gui/qt4/main_interface.cpp |   23 +++++++++++++++++++++++<br>
 modules/gui/qt4/main_interface.hpp |    1 +<br>
 2 files changed, 24 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/modules/gui/qt4/main_interface.cpp<br>
b/modules/gui/qt4/main_interface.cpp<br>
index 193bf7f..1c26a03 100644<br>
--- a/modules/gui/qt4/main_interface.cpp<br>
+++ b/modules/gui/qt4/main_interface.cpp<br>
@@ -1145,6 +1145,29 @@ void MainInterface::changeEvent(QEvent *event)<br>
         }<br>
     }<br>
<br>
+ else if( (event->type() == QEvent::ActivationChange) )<br>
+ {<br>
+ if( THEMIM->getIM()->playingStatus() == PLAYING_S &&<br>
+ THEMIM->getIM()->hasVideo() &&<br>
+ !THEMIM->getIM()->hasVisualisation() &&<br>
+ var_InheritBool( p_intf, "qt-pause-minimized" ) )<br>
+ {<br>
+ b_hasPausedWhenInactive=true;<br>
+ THEMIM->pause();<br>
+ }<br>
+ else if(THEMIM->getIM()->playingStatus() == PAUSE_S &&<br>
+ THEMIM->getIM()->hasVideo() &&<br>
+ !THEMIM->getIM()->hasVisualisation() &&<br>
+ var_InheritBool( p_intf, "qt-pause-minimized" ) )<br>
+ {<br>
+ if(b_hasPausedWhenInactive)<br>
+ {<br>
+ b_hasPausedWhenInactive=false;<br>
+ THEMIM->play();<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
     QWidget::changeEvent(event);<br>
 }<br>
<br>
diff --git a/modules/gui/qt4/main_interface.hpp<br>
b/modules/gui/qt4/main_interface.hpp<br>
index cfac21f..dfd0935 100644<br>
--- a/modules/gui/qt4/main_interface.hpp<br>
+++ b/modules/gui/qt4/main_interface.hpp<br>
@@ -168,6 +168,7 @@ private:<br>
 //    bool                 b_visualSelectorEnabled;<br>
     bool                 b_plDocked;            ///< Is the playlist docked<br>
?<br>
<br>
+ bool b_hasPausedWhenInactive;<br>
     bool                 b_hasPausedWhenMinimized;<br>
     bool                 b_statusbarVisible;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110912/844576f4/attachment.html" target="_blank">http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110912/844576f4/attachment.html</a>><br>


-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: pause_when_inactive.patch<br>
Type: text/x-patch<br>
Size: 2106 bytes<br>
Desc: not available<br>
URL: <<a href="http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110912/844576f4/attachment.bin" target="_blank">http://mailman.videolan.org/pipermail/vlc-devel/attachments/20110912/844576f4/attachment.bin</a>><br>


<br>
------------------------------<br> ____________________________________</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
vlc-devel mailing list<br>
<a href="mailto:vlc-devel@videolan.org" target="_blank">vlc-devel@videolan.org</a><br>
<a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
<br>
<br>
End of vlc-devel Digest, Vol 52, Issue 32<br>
*****************************************<br>
</blockquote></div><br><div>Sorry, the previously attached patch won't apply, it gives 'trailing whitespace' error/warning. </div><div>Here's the patch applies cleanly (also attached as plain-text file) . The patch implements the auto-pause when window not active feature.</div>

<div><br></div><div>Author: Sanjeev M K <<a href="mailto:sanjeevmk4890@gmail.com">sanjeevmk4890@gmail.com</a>>  IRC Nick: s-mk</div><div><br></div><div><div>diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp</div>
<div>index 193bf7f..f3bb2aa 100644</div><div>--- a/modules/gui/qt4/main_interface.cpp</div><div>+++ b/modules/gui/qt4/main_interface.cpp</div>
<div>@@ -1145,7 +1145,29 @@ void MainInterface::changeEvent(QEvent *event)</div><div>         }</div><div>     }</div><div> </div><div>-    QWidget::changeEvent(event);</div><div>+<span style="white-space:pre-wrap">       </span>else if( (event->type() == QEvent::ActivationChange) )</div>

<div>+<span style="white-space:pre-wrap"> </span>{</div><div>+<span style="white-space:pre-wrap">               </span>if( THEMIM->getIM()->playingStatus() == PLAYING_S &&</div><div>+<span style="white-space:pre-wrap">                      </span>THEMIM->getIM()->hasVideo() &&</div>

<div>+<span style="white-space:pre-wrap">                 </span>!THEMIM->getIM()->hasVisualisation() &&</div><div>+<span style="white-space:pre-wrap">                   </span>var_InheritBool( p_intf, "qt-pause-minimized" ) )</div>

<div>+<span style="white-space:pre-wrap">                 </span>{</div><div>+<span style="white-space:pre-wrap">                               </span>b_hasPausedWhenInactive=true;</div><div>+<span style="white-space:pre-wrap">                           </span>THEMIM->pause();</div>

<div>+<span style="white-space:pre-wrap">                 </span>}</div><div>+<span style="white-space:pre-wrap">               </span>else if(THEMIM->getIM()->playingStatus() == PAUSE_S &&</div><div>
+<span style="white-space:pre-wrap">                            </span>THEMIM->getIM()->hasVideo() &&</div><div>+<span style="white-space:pre-wrap">                            </span>!THEMIM->getIM()->hasVisualisation() &&</div>
<div>+<span style="white-space:pre-wrap">                         </span>var_InheritBool( p_intf, "qt-pause-minimized" ) )</div><div>+<span style="white-space:pre-wrap">                     </span>{</div><div>+<span style="white-space:pre-wrap">                               </span>if(b_hasPausedWhenInactive)</div>

<div>+<span style="white-space:pre-wrap">                         </span>{</div><div>+<span style="white-space:pre-wrap">                                       </span>b_hasPausedWhenInactive=false;</div><div>+<span style="white-space:pre-wrap">                                  </span>THEMIM->play();</div>

<div>+<span style="white-space:pre-wrap">                         </span>}</div><div>+<span style="white-space:pre-wrap">                       </span>}</div><div>+</div><div>+<span style="white-space:pre-wrap">       </span>QWidget::changeEvent(event);</div>
<div> }</div><div> </div><div> /************************************************************************</div><div>diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp</div><div>index cfac21f..dfd0935 100644</div>

<div>--- a/modules/gui/qt4/main_interface.hpp</div><div>+++ b/modules/gui/qt4/main_interface.hpp</div><div>@@ -168,6 +168,7 @@ private:</div><div> //    bool                 b_visualSelectorEnabled;</div><div>     bool                 b_plDocked;            ///< Is the playlist docked ?</div>

<div> </div><div>+<span style="white-space:pre-wrap"> </span>bool<span style="white-space:pre-wrap">                            </span> b_hasPausedWhenInactive;</div><div>     bool                 b_hasPausedWhenMinimized;</div>
<div>     bool                 b_statusbarVisible;</div><div> </div></div>