I am able to play the videos in exoplayer using the source code at https://github.com/google/ExoPlayer, but unable to find, how to save video and play later while offline.
Also how segmented videos running through mpd files will be saved offline?
Any code snippet that I can put inside the exoplayer source code to make it work would be highly appreciable.
You can use a CacheDataSource and wrap your data source with it (eg. wrap the DefaultHttpDataSource).
Related
Which library is useful to load audio or video file from API and play to the application? I tried glide for the image. But no idea about audio or video. (I want to fetch the image and file name to the recycle view after click operation file will play to the next activity.) A short guideline with library name is very helpful.
Android has MediaPlayer to load and play Audio and Video from URL. you can setDataSource as URL.
refer this answer...
You have Two approach one of them is using official Library (Media Player Library for music and VideoView for video) and other approach is using custom library I suggest you to using ExoPlayer Library for playing music and video
you can use following link:
https://github.com/google/ExoPlayer
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.
I download video with:
mPlayer.setDataSource("https://s3-eu-west-1.amazonaws.com/ellovidsout/1232/9/1423065486.mp4.m3u8")
Header contains following data:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=532000,RESOLUTION=400x224,CODECS="avc1.42001e,mp4a.40.2"
400k_1423065486.mp4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1273000,RESOLUTION=640x360,CODECS="avc1.4d001f,mp4a.40.2"
1000k_1423065486.mp4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2476000,RESOLUTION=1024x576,CODECS="avc1.4d001f,mp4a.40.2"
2000k_1423065486.mp4.m3u8
Can I manually force media player to play only video with resolution 400x224 for example? (Except manually alerating url adding quality code to id)
You can use the method selectTrack and getTrackInfo Therefore, it doesn't work properly for all devices and Android OS version.
It might be helpfull to use ExoPlayer . Here you can check the demo app.
I have video uploaded on server. which is trailer of movie. I can play this video direct to my videoView with the help of live url. My question: is there any method in android which help me out to get a video frame from url without download the video to local storage. I know one method name "createvideothumbnail" but it will not work in my case. because i need to get the video thumbnail without download the whole video. as you have seen the mechanism is implemented in imdb official app (Trailer section).
Please help, thanks in advance
Getting thumbnails without download the complete video is not possible until now (API Level 22) i´m pretty sure that the application that you describe load thumbnails that were created previously.
the current option would be using the class:
import android.provider.MediaStore.Video.Thumbnails;
or create the thumbnails in a separated process.
I am developing an app. that will stream the video recorded from camera and stored as mp4 in sdcard...
I know there something called as RTSP which is used for that...
Please tell me where to start . .and is there any library that will do this for me...
I do not understand why you want to stream a local mp4 file, but maybe I misunderstood you problem. RTSP is used for live streaming, but you want to play a local mp4 file.
If you want to capture video and save it as mp4 onto a SD card, you need to use the Android MediaRecorder. Here a link to a simple example.
If you just want to playback a local mp4 file. Have a look at the Android API Demos.
These are part of the Android SDK installation and contain a good example of how to playback local media files.