How to create snack.expo audio player - android

I am currently working on a snack.expo music app using expo-av. I am have trouble with the sound playing part.
Working
swipe for next/prev song(only changes image, name, artist)
use next/prev button(only changes image, name, artist)
Playing correct sound
Help Needed
pausing and playing sound
adding functionality to bottom buttons
implementing slider
I need to grab sound data from data.js and I need to play it based on which image is shown on screen. Right now there are just sample sounds and images.
snack link (almost full code)

Related

YouTube Player next prev buttons aren't visible for the first video

I'm trying to implement built-in YouTube player in my app (API: https://developers.google.com/youtube/android/player/)
I load more than one video id for playback (list of video IDs)
youTubePlayer.loadVideos(idList)
But when player starts prev and next buttons aren't available until the first video finishes and switches to the next one, only then buttons appears and I can switch between videos from my video list
Whenever you got the answer.... please lemme know
It started to work normally after some time

mediaplayer.pause() not working

I am playing audios in a gridview.I am having issue that once the audio starts it not pausing or stopping.On clicking on pause button I see the pause image changing to play but still the audio keeps playing.If i click on another item's play button then multiple audio plays.I failed to understand why mp.pause() not working?
You are creating a MediaPlayer for each item of your GridView. If you scroll, it will mess up the references to your view and you won't be able to handle your MediaPlayer. You should use only one MediaPlayer, like the one you already have declared mMediaPlayer. Try using it instead of creating one for each item.

Play audio on button click in viewpager efficiently in android

In my application I am displaying around 30 animal images using viewpager. each page has full screen image and play sound button. Clicking on button will play displayed animals sound. So there are 30 different sound files in raw folder. how to play audio effectively when user press button? What to use mediaplayer or soundpool? and how to use it effectively? Please give me solution.
Keep the song files in the raw folder and then on the button's onClick method execute the songs play.
You can use a switch case for different id's of button.

Android Video view ceating black window while make it gone

My application has several pages of book. In some of page I am playing video using video view. I am checking if I have any video for that page. If yes, than I am making videoview visible and passing Uri. If not, I am making it gone.
Now the problem is, once i reached to that screen and then if I swipe left/right it's creating black window in every subsequent screen. Why?
I found solution. When you want to show video make videoView.setZOrderOnTop(false); and when you want to hide video view jusr make videoView.setZOrderOnTop(true);

Android VideoView Update Subtitles

I'm trying to make a video player with VideoView that supports subtitles using a TextView on top of it.
I've already parsed the subtitles but now i need an event that runs every time a frame changes or so to update the subtitles with the current playing position.
I tried making a thread but I am not able to change my TextView in that separate thread. Is there an event on VideoView/MediaPlayer that runs every frame change that I can override to call my updateSubtitle method?
Starting with Android 4.4 , you can put subtitles from within the VideoView itself:
https://www.youtube.com/watch?v=hCRGc2PcmB8#t=130
Coming to your first question, there is no event that happens each video frame. Having said that there are ways of getting current time and synchronize subtitles to the current time. Below links might be of help
A white paper on how to support subtitles in Android

Categories

Resources