Android Exoplayer caching m3u8 audio for offline support - android

I am creating a music application.
I have used Exoplayer V2.8.0, So far I have achieved to play, pause next, prev, shuffle, repeat all songs using controls in-app and also with notification.
But all of this works only in online mode.
Now I want to add offline support to this app and allow a user to download the song offline and play while they are offline.
Audio files we are getting are *.m3u8 files.
But my problem is user should not access those downloaded files outside of my app. I have tried using one approach but it gives the mp3 files downloaded and combined from the different segments of the m3u8 file.
Can anyone guide me or give me sample or tutorial on how can I download the segments only and at the time of playing I can use that segment and play audio offline?

There is one suggestion for you,
If you want to create an offline player with .m3u8 or any other file then after download saves your file into your package folder with some of the different formats. Then while using that convert that specific formatted to mp3 or other which will help out for offline music play.

You can use a local http proxy server (NanoHttpd). Start the server and point your ExoPlayer to 127.0.0.1 so you can monitor the requests. Cache the m3u8 playlist plus the downloaded files for the first time you see a request. Next time when your proxy detects the same request, just play the files from cache.

Related

Android code : How to use YOUTUBE OFFLINE functionality for .mp3 files?

I am developing an android application for Online Music streaming. I want to download MP3 files from the server and play that file when the user is offline. And the downloaded file can only be played through applicaion
please give your best solution

Streaming Audio from server to Android App

I am kind of stuck on my app design and wondering, if some of you experts, could point me in the right direction.
I am working an Android App that shows how to pronounce different English words.
When user clicks on a play button next to a word, corresponding audio file (prerecorded wav file) is played with Android media player. I have 2000 words and corresponding wav files (each file is between 1 to 2 seconds).
But the problem is, I can’t pack all 2000 audio files into APP, as it will make APP too big. I am wondering, what is the best way of having the audio files on the server somewhere, and when user clicks play button next to a word, my APP plays from server. Are there any other ways of doing this?
Do I need streaming server for this (it’s not live stream), if so would you please let me know some that host? Can I use Heroku?
Thanks for help
Srini
You do not need a streaming server for that. A simple web pages server will do the job. Just put all your files in (maybe via ftp) to the server in a directory that you now exactly. From there, you can use the MediaPlayer class of android to play those sounds in streaming with the appropriate link to the file.

Widevine and MPEG-DASH - offline playback

I have created an Android application which is capable of playing movies, which are protected with DRM (Widevine Modular). Video are in MPEG-DASH standard. In case, that device is online, everything works fine.
Now I need to add feature for playing video in offline mode. The problem is that I do not know how can I download some file(s) for offline playback. Everything what I have is .mpd file, which contains structured data.
How can I get some file(s) for download from this manifest .mpd file? There are no direct links to some video. I see some chunk, which looks like this:
media="chunk_ctvideo_cfm4s_rid$RepresentationID$_cs$Time$_w1003607280_qaWQ9QVBsSUxIMUpaRnVfdfdfkstMDImYXdsgdreaW9pbmRleD0w_mpd.m4s
I do not know if it is useful for me, but there is nothing more "noticeable" in the manifest file.
For an example of code that processes a manifest and downloads the media chunks have a look here: https://github.com/axiomatic-systems/Bento4/blob/master/Source/Python/utils/mp4-dash-clone.py
Of particular interest you may find the ProcessUrlTemplate which shows how to pass the media elements to get a URL for a chunk

Playing m3u8 form local storage

We want to play m3u8 with ts files stored locally on SD card in Android 4.0 and above devices.
I tried using video TAG inside HTML residing locally on the SD card and android native media player.
Both the codes are failing with the error. The same set of ts and m3u8 files are working fine when played from online when served from a webserver connected through http.
Can we play m3u8 using native support for files stored offline or do we need to use 3rd party libraries. I searched in internet and didn’t find article about not supporting the same.
Any help or recommendation would help my work.
Thanks a lot
Issue Solved
we used nano http server to serve m3u8 file to with all videos parts. Very simple and easy way to play m3u8 video file.

Phonegap Android App - Display Store MP3 Media

I've been following this blog to help me make a simple music player function with an Android app (http://simonmacdonald.blogspot.com/2011/05/using-media-class-in-phonegap.html).
All works well - but I would like some way to extract a list of all music media stored on the phone so the user can click a file and play it. Does anyone know if this is possible via phone gap? I'd need to access track name/artist etc and a link to the track.
Cheers
Paul
Prognosis is not good.... PhoneGap does not have an API for accessing the media library. So, you would have to fall back to the File API to locate music files, and then... you would have to read the binary data in the actual files to extract out the track/artist metadata. Ouch. Seems pretty impractical.
[EDIT]
By the way, PhoneGap is not the only game in town. Appcelerator seems to solve the same problem, and apparently has a richer API, which includes
access to media metadata

Categories

Resources