• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Stopping Video within SwipeView

gazzieh

Newbie
Aug 21, 2013
22
3
Partly putting this up because it will eventually help others looking for a solution but also because I have no solution yet.

I have an app that uses SwipeView. 4 pages in all, each page with some text and a video (different on each page).

Currently you can click on a video then swipe to the next page and click on the next video whilst the other still plays. You could potentially have all 4 videos playing at the same time.

How can I stop a video playing once the page it is on is not the one with the SwipeView focus?
 
It does indeed but there is a strange reaction to this. Page 1 to Page 2 works fine and Pages 3 and 4 appear fine but Page 2 to Page 1 and the video continues.

Also, some of the videos take several taps to begin playing again!

I missed the code first time I submitted this so:

[HIGH]@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
{
VideoView videoView = (VideoView) findViewById(R.id.vidView);
if (videoView.isPlaying()) {videoView.stopPlayback();}
}[/HIGH]
 
Upvote 0
A semi-workaround was to replace the .stopPlayback() with a .pause() and a .seek(0).

Now all the videos play and the videos either stop when I swipe to another page or they stop when I swipe and then return. Not ideal but since time is now almost gone this will work for deployment and then I can update it later (this is a single tablet app so not sending it out to anything or anyone else).
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones