I'm trying to create an AWS video streaming App on Android. but I have to download the video for offline streaming. but thing is that I want to hide the video files, like youtube or NetFlix.so if anyone can explain how to hide downloaded files....pleasse help me . Thank you :)
You can use app-specific files directory, no one can see files...
You can access files directory via,
in Kotlin
val file = File(context.filesDir, filename)
in Java
File file = new File(context.getFilesDir(), filename);
for more details https://developer.android.com/training/data-storage/app-specific
Related
I working on media application, On app user able to watch video on any video player. all media file is stored in Internal Storage which is .mp4 formate in particular folder called LearningVideo.
My question is I want to encrypt that video so a user won't able access that and also decrypt that video when app play that.
So how can I achieve this task, please help me.
I tried com.google.android.exoplayer:exoplayer:2.6.0
Use CipherOutputStream and CipherInputStream for encryption and decryption of file in android.
There are two ways through which you can achieve your goal
Download a file and encrypt it, when you want to play that file decrypt it in a temporary file and play it.
if you want to play the encrypted file on the fly (not decrypting it in a temp file) then you can use Libmedia library. It streams encrypted file on localhost and plays it from there
Try to write Files inside FilesDir may be this solved your issue
File rootpath = getApplicationContext().getFilesDir();
File path = new File(rootpath.getAbsolutePath() + "/LearningVideo");
You can store your files inside /data/user/0/<packageName>/files
Iam a learner of creating android custom app. I create simple app using HTML files via Quick-App-v1.1. I have include the audio file in html file. it's properly play when open the HTML file in browsers, but when create the app the audio file not playing. Please advice me.
Create a folder in Android Studio under 'res' and name it 'raw'.
Copy your audio file to the raw folder.
To play the audio file you can use something such as:
MediaPlayer song;
//then play it inside your onCreate
song = MediaPlayer.create(this, R.raw.YOUR_SONG_NAME);
song.start();
Check this out:
http://developer.android.com/reference/android/media/MediaPlayer.html
I am working on an android app that can download videos in different formats.It done perfectly.
Now i want to extract audio from downloaded video file or available video link.
Is there any way to extract audio from video by any of the following methods
1.extract audio directly from a video file link
or
2.is there any library that suitable for android to extract audio from a video files
Thanks for your time!
You can use a library called JAVE (Java Audio Video Encoder) to encode a video into an audio file.
Download JAVE from here.
Refer to the below snippet to encode from MP4 to MP3
Code:
File source = new File("source.mp4");
File target = new File("target.mp3");
AudioAttributes audioAttributes = new AudioAttributes();
audioAttributes.setCodec("libmp3lame")
.setBitRate(new Integer(128000))
.setChannels(new Integer(2))
.setSamplingRate(new Integer(44100));
EncodingAttributes encodingAttributes = new EncodingAttributes();
encodingAttributes.setFormat("mp3")
.setAudioAttributes(audioAttributes);
Encoder encoder = new Encoder();
encoder.encode(source, target, encodingAttributes);
JAVE is basically a wrapper over FFMPEG, for this simple FFMPEG is a very big framework to use which also increase the app size. I can check a gist of mine performing the thing by using Android native API's (MediaExtractor & MediaMuxer). From the attached URL:
https://gist.github.com/ArsalRaza/132a6e99d59aa80b9861ae368bc786d0
my samba Share file path is : smb://10.0.0.18/MZAES_Songs/Aashiqui 2/Asan Nahin Yahan.mp3
How can I give this path to android mediaPlayer?
For example for local memory file can be played as
String filepath = "sdcard/emulated/0/ashqui/asaa.mp3";
mediaplayer.setDataSource(filePath");
mediaPlayer.prepare();
mediaPlayer.start();
etc..
But how to do with samba shared file path...
Actually Media Player can't play samba share files( as per my knowledge ). So you have to select another way to play those files.
I had solved this problem in this way,
By using NanoHttpClient( 3rd party API ). This API(library jar file), you can get it from Google search.
Download and integrate it to your project.
Then serve your smb file on your device only.
And give that path to your Media Player( http link ). Hope i have answered well.
I am creating an own application for android that generates playlists. Application creates .m3u files in UTF-8 encoding format. Files exist and visible in file manager, but media players don't see the playlists and this is a problem. Playlists files are correct and work properly in build-in player in file manager.
Here is some part of the code, that gererates playlists:
File file = new File(Environment.getExternalStorageDirectory() + "/Music","Test.m3u");
PrintWriter writer = new PrintWriter(file, "UTF-8");
...
writer.println(PathToSong.toString()+"\r");
....
writer.flush();
writer.close();
I downloaded a program from Play Market that also creates playlists (.m3u) files. Playlists files that are built by the program have the same format as mine, but visible for media players. The most interesting thing is: ater launch the program from Play Market, playlists from my own program becomes visible for media players too.
Also my playlists become visible for the media players after restarting the phone. I develop and test my application using Android Studio 0.3.4.
I found the answer. It is needed to run media scanner so that mediafiles(photo, music, etc.) become visible in applications. Media Scanner runs automatically after phone restart.
To run Media Scanner manually you just need to paste and run this part of code:
UpdateMediaIntent = new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()));
sendBroadcast(UpdateMediaIntent);
Hope, it will be helpful for somebody else too.