Extracting and Streaming audio from YouTube videos in Android - android

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?

Related

control the quality of video manually in exoplayer

is there anyone who can help me to find a neat coding style in a simple way to set a control in my android app that user can change the quality of video manually. im using exoplayer
im looking for the answer for a while and the demo app is so complicated

Check/observe what is currently being played by the Android system

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?

How to play videos in recycler view?

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.

Changing bitrate of Exo Player

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.

Android MediaPlayer persistent cache using ExoPlayer

I'd like to implement a persistent cache for streamed audio data in my app.
I've scoured the internets and looked at the few existing solutions, most of them require you to create a local proxy, which writes the data to cache as well as serving it to Android's built-in MediaPlayer.
I finally came across Google's ExoPlayer which appears to do exactly what I want it to! I believe in order to create the cache I need to use CacheDataSource, however I can't figure out how to use it!
I've been through the Google documentation and demo app but they don't provide much info about caching at all.
Could anybody help me out and provide an example?
Never used this but the following tutorial on how to construct an audio renderer seems pretty straight forward to me. http://google.github.io/ExoPlayer/guide.html#datasource
May I ask why you want to implement persistent caching with a media player? When I made use of google's MediaPlayer framework it seemed pretty useful to me, never had a problem with streaming as long as I have a data connection.
I had also been searching endlessly for a solution for caching audio for the purpose of offline playback availability.
I finally found this library:
https://github.com/danikula/AndroidVideoCache
Also it is called Android Video Cache, it works for caching audio as well.

Categories

Resources