The app crashes when I scroll the recyclerview . I know why this happens . But I don't know how to prevent it . There are very less resources online on how to smoothly play videos in recyclerview . Facebook,instagram has done it.(even though they use react native).But what about the android studio users????..Is there a way to play crash free videos in recyclerview?
NOTE
The app crashes because
VideoView extends SurfaceView, and SurfaceView doesn’t have UI synchronization buffers.If by chance the app doesn't crashes then video that is playing tries to catch up the list when you scroll it. That looks horrible!!
You can use ExoPlayer.
for such complex task,and it also provides much more facilities.
Here is the link.
ExoPlayer is an application level media player for Android. It provides an alternative to Android’s MediaPlayer API for playing audio and video both locally and over the Internet. ExoPlayer supports features not currently supported by Android’s MediaPlayer API, including DASH and SmoothStreaming adaptive playbacks. Unlike the MediaPlayer API, ExoPlayer is easy to customize and extend, and can be updated through Play Store application updates.
For using it,just in Gradle file:
implementation 'com.google.android.exoplayer:exoplayer:2.X.X'
For complete details,you can see the blog about how to use it,and its features,i hope it may be useful to you.
If its not the answer,please ignore the answer.
Related
Im planning to port old audio play app to andriodx. My app has audio tracks crossfade, gapeless feature implemented using MediaPlayer and VolumeShaper. It's a mandatory functionality for me.
Exoplayer is missing crossfade capability - it has been in the features backlog for many years unfortunately.
Any ideas if there is a way to access MediaPlayer and VolumeShaper from within Exoplayer. Perhaps anyone knows about audio tracks crossfade implementation with Exoplayer?
Thanks in advance!
David
Find a guidance and/or source code sample.
I'm trying to find a way to separate and stream the audio from a youtube video given it's url/video ID. I've looked into youtube extractors and most of them are pretty old or no longer maintained. I'm working in Kotlin and jetpack compose. I found an app, newpipe, that does exactly what I want, but the codebase is huge and it's way beyond my experience. I'd like to play it in the background as well, so I suppose I would use exoplayer in combination with a background service. My only obstacle is obtaining the audio from it's url. Is there a quick and dirty way to achieve this within the context of an Android app?
I'm looking for a solution to observe what the app is currently playing. At minimum I would need to know what URI is being used to play Media and what is current playback position.
We are giving developers API with media content (MP3/HLS files) and to give them the best experience we are asking them to send various events to our API. Based on those events we can prepare better content for their users. We would like to ease the process of tracking events by implementing library that will be responsible for tracking those events. To do it we need to observe/query what their app is currently playing and what is a playback position. That's why I'm looking for a solution that will let me do this without caring too much what kind of player app is using (MediaPlayer, ExoPlayer or any other solution).
Is there any tool that will let me check those informations?
I am going to create InApp Video player which will play the videos from our content server and will also support live streaming. Previously was using third party API.
I am confused about going with SurfaceView or VideoView as I have read that VideoView has more lines of code and will be less efficient. Help needed regarding from where should I start? Also need clarity between both. Yes, I have gone through some questions but still confused.
Thank you in Advance.
Frankly Speaking,
VideoView is the combination of SurfaceView and MediaPlayer,
VideoView = SurfaceView + MediaPlayer
But advantage of using Surfaceview and MediaPlayer separately is that you will have the ability to customize it.
I just used VideoView few days ago in my app. I actually had the same confusion. Since, then I came to know about it. I used VideoView. Here is the link below
Link
Hope it helps
This question might have been asked many times. I searched everywhere but could not find the correct answer. I am using ExoPlayer in my project to play HLS videos.
I want to give user the option to select the bandwidth of videos. Something like what YouTube does.Any idea how this can be achieved using ExoPlayer?
From ExoPlayer issue tracker:
ExoPlayer currently selects the first variant listed in the master
playlist. If I remember correctly, this is what Apple
recommends/specifies as correct client behavior. If you want to start
in the lowest quality, you should technically have your server
generate the master playlist with the lowest quality listed first.
The above aside, we do agree that it makes more sense for the client
to make the initial variant selection locally, as opposed to the
recommended behavior. We'll be moving HLS over to use FormatEvaluator
in ExoPlayer V2, which will give more control over the initial
selection (and over the adaptive algorithm in general).
And as the solution, this comment:
Have a look at AdaptiveTrackSelection.Factory. Its parameters may
provide enough customization for your case.
I think this should give you either the answer you need, or it will guide you in the right direction.
Note that you have to provide streams in lower qualities to be able to use this. If you ONLY have the video in HD, ExoPlayer can't downsample the video, its not its job and not what it is intended for. ExoPlayer can only sync and enable smooth transition between the video in multiple resolutions when they are provided.