tcking / GiraffePlayer2

out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Apache License 2.0
377 stars 110 forks source link

How to pause video when come back to the activity? #172

Open yangxu4536 opened 5 years ago

yangxu4536 commented 5 years ago

i play video in a activity, and i pause the video when swith to other app. when i come back to my app, the video auto play. i want video to stay pause because i pause it when last leave.

prakashmp commented 5 years ago

In your base activity place this code in onPause() method

@Override public void onPause() { super.onPause(); try { if (PlayerManager.getInstance().getCurrentPlayer() != null) { PlayerManager.getInstance().getCurrentPlayer().onActivityPaused(); } } catch (Exception e) { e.printStackTrace(); } }

yangxu4536 commented 5 years ago

I try it but not solve my problem, can you give more detail infomation?

yangxu4536 commented 5 years ago

when from back to front, the log are below: image

prakashmp commented 5 years ago

PlayerManager.getInstance().getCurrentPlayer().pause(); >> use this and check whether still audio in background or not ??