[Android] Save video pause status with a flag

Jean-Baptiste Kempf jb at videolan.org
Tue Jan 6 15:43:35 CET 2015


On 05 Jan, Edward Wang wrote :
> On 2015-01-06 03:37, Jean-Baptiste Kempf <jb at videolan.org> wrote:
> >On 05 Jan, Edward Wang wrote :
> >>>+            // Paused flag
> >>>+            boolean wasPaused = mSettings.getBoolean(PreferencesActivity.VIDEO_PAUSED, false);
> >>>+            if(wasPaused) {
> >>>+                Log.d(TAG, "Video was previously paused, resuming in paused mode");
> >>>+                mHandler.postDelayed(new Runnable() {
> >>>+                    @Override
> >>>+                    public void run() {
> >>>+                        mLibVLC.pause();
> >>>+                    }}, 500);
> >>>+            }
> >Sorry, but this is overly ugly.
> >
> >What if the video takes more than 500ms to open? What if it takes less?
> 
> This is modelled after existing code in VideoPlayerActivity.java:680, with
> the case of pause due to lock screen.

postDelayed is almost always a bad idea.
Adding a hack because there is another hack is not a great idea.


-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the Android mailing list