Hello
our tester want to stop function in video player.
so I add stop button and call seekto(0) and pause when user press stop key.
but I has one problem. videoview is not clear play screen.
please help me.
instead of using video view try media player present in android.mediaplayer.mediaplayer so when you need to stop the player you can just call mediaplayerobject.stop() and then mediaplayerobject.release() thats all it will be easy
Related
I know I could test with PlayerStateChanged if something is playing or not but I need the moment someone presses the play button... Does somebody know the code for this ?
I want to make the player prepare(mediasource) only when the user clicks on the play button so I can save ressources otherwise it will keep loading everytime a video when I go into the feed.
Then you can just simply add a button to your layout and call prepare(mediaSource) whenever button is clicked.
BTW : you can override the control view of ExoPlayer to achieve the same
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
Is there a way to have a media file (audio/video) running in a cardview layout? I want to have a video preview of the file inside a card layout, when the user clicks on the card the video/audio is taken fullscreen and played, just like Facebook's feed.
In order to get that kind of functionality you have to solve a few problems:
You cannot use VideoView in a list because it is extending SurfaceView, and if playback is on and user starts scrolling, the visual effect will look like video is trying to catch the scroll. So you need a special VideoView that is based on something else, for example TextureView.
Managing video player state:
in order to start/stop playback we need to call a few methods of MediaPlayer.class:
setDataSource()
prepare()
start()
stop()
reset()
release()
These methods are direct calls to hardware and it may take some time before hardware will respond. So we cannot call it in UI thread. It will block it for more than 16 milliseconds, so user will see a lagging scrolled list. We have to call it from a background thread.
You need to track in run time which view on the screen is active and this view should be playing.
I've created an opensource project called VideoPlayerManager.
It is thoroughly documented and some basic flows are handled in the demo application. It is not ready for production but if you need some reference of how to get this kind of functionality, you can find it there.
P.S. Regarding CardView: it is a regular view. You can put a video player into it and get video playback in CardView.
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.
I have one activity where i got two video URL.So, once the activity started i have set one progress dialog which spins till the first video is prepared.So once first video started , i want to buffer the second video in background(First Video is still playing in foreground).Right now i am showing one progress dialog till the video prepared.So once the first video is finished ,i want to immediately start the second one.So user feels like that its an one video.
Any help will be appreciated....
Thanks in Advance....