How can I attach a sound to each ViewPager image

27 Views Asked by At

I am newbie. I can't find an answer. I have a ViewPager with a stack of swipeable images.

I need to make it so that when a certain picture is opened, the sound that is assigned to it is played. Tell me in which direction to look, so far I can only make the sound play when the first picture is opened, just by launching the MediaPlayer, but this is not at all what I need.

1

There are 1 best solutions below

0
snachmsm On

check out onPageChangeListener (first answer with example) or even SimpleOnPageChangeListener - play desired music in onPageSelected(int position) method