Convert CipherInputStream to FileInputStream - android

I am using nano-httpd to play encrypted mp3 file. I want to play encrypted file on the fly. I apply decryption AES-256 and send the CipherInputStream file to NanoHttpd but it throws exception. Actually it requires FileInputStream. Errors are stated below
return new NanoHTTPD.Response(Response.Status.OK, "audio/mpeg", CipherInputStreamFile); // here it requires FileInputStream File
**Exception**
D/MediaPlayer: Couldn't open file on client side, trying server side
E/MediaPlayer: error (1, -2147483648)
E/MediaPlayer: Error (1,-2147483648)

Related

Android media player error status messages?

In my application, I am playing files from URL using MediaPlayer API.
It plays the remote file very well, the problem comes while handling errors,
1] When a file is not available on a remote URL (i.e. 404)
error message in IOExcpeiton reads, "Prepare failed.: status=0x1"
2] When the phone is not connected to internet exception message is same i.e.
"Prepare failed.: status=0x1"
How do we differentiate between 404 & no connectivity states for better handling of exceptions?
So far I have understood the IOException with the error message "Prepare failed.: status=0x1" appears only when a requested resource file or URL not available
For Error : Prepare failed.: status=0x1
Ref: Android MediaPlayer throwing "Prepare failed.: status=0x1" on 2.1, works on 2.2
I do not know if this is your issue, but I just found a solution to the problem the described by Tuszy above. I could read the file I was creating from external storage but not from Cache.
The solution is that the read write permissions when writing the file are different.
Please see this excellent explanation in this blog I found.
http://blog.weston-fl.com/android-mediaplayer-prepare-throws-status0x1-error1-2147483648/
Ref : Internet Connection Error
getting an UnknownHostException will mean that the application was
able to connect to the Internet
No it doesn't. It means the application was unable to resolve the host name. That could be because the host name doesn't exist, or because it was unable to connect to the Internet to resolve it.
When there is no Internet connection.
No specific exception. "There is no Internet connection" doesn't have a well-defined meaning. The condition resolves to one of the other failure modes below.
When the URL cannot be found.
If the host cannot be found, UnknownHostException. If the content part of the URL cannot be found, HTTP 404.
When the request timed out.
ConnectException with 'connection timed out' as the message, or SocketTimeoutException if it's a read timeout.
When the website is down.
ConnectException with 'connection refused' as the message.
When access is denied.
HTTP 403.

Android media player can't play ogg files

I'm using MediaPlayer library to stream some audio files from my server. The problem is when I want to play ogg audio file with media player in android version 4.2.2 and it's ok when I play it in android nougat. It gives me this error while preparing ogg audio file:
E/Tag: Prepare failed.: status=0x106
E/MediaPlayer: error (1, -2147483648)
E/MediaPlayer: Error (1,-2147483648)
E/MediaPlayer: stop called in state 0
Is there any alternative way to stream ogg format in all devices?
by the way there is no problem with playing mp3 files in all android versions I'v tested.
Thank you ...
First you should add <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Then set data source, maybe:
mp = new MediaPlayer();
mp.setAudioStreamType(AudioManager.STREAM_RING); will help;
And of course prepare file before start:
mp.prepare();
mp.start();

Mediacodec for decoding H264 stream failed to create on Nexus 6P

I have an application (decoding module) which fails to create mediacodec for decoding H264 encoded stream while running on the Nexus 6P. But it perfectly works under Google PIXEL XL phone.
I am also giving a small snap of the error I am getting while I debug it using android studio logcat. Any Help will be highly appreciated.
Error Snap
E/OMX-VDEC-1080P: Failed to call stream on OUTPUT due to HW_OVERLOAD
E/OMX-VDEC-1080P: empty_this_buffer_proxy failure due to HW overload
E/OMX-VDEC-1080P: ERROR: Sending OMX_ErrorInsufficientResources to Client
E/OMX-VDEC-1080P: Failed to qbuf to driver
E/ACodec: [OMX.qcom.video.decoder.avc] ERROR(0x80001000)
E/ACodec: signalError(omxError 0x80001000, internalError -2147483648)
Codec reported err 0x80001000, actionCode 0, while in state 6
E/NuPlayerDecoder: Decoder (video) reported error : 0x80001000
E/NuPlayer: received error(0x80001000) from video decoder, flushing(0), now shutting down
E/MediaPlayer: error (1, -2147479552)
E/MediaPlayer: Error (1,-2147479552)
D/EasyMovieTexture: OnError
E/NuPlayerDecoder: failed to flush OMX.qcom.video.decoder.avc (err=-38)
12-29 20:21:41.075 2737-10644/? E/NuPlayer: received error(0xffffffda) from video decoder, flushing(2), now shutting down
D/NuPlayerDriver: notifyListener_l(0xeed2aae0), (100, 1, -38), loop setting(0, 0)
E/MediaPlayer: Error (1,-38)
D/EasyMovieTexture: OnError
E/OMX-VDEC-1080P: Failed to call stream on OUTPUT
E/OMX-VDEC-1080P: empty_this_buffer_proxy failure
I guess error code -38 is coming because I want to start the mediaplayer in an incorrect state (Here as the codec is giving me an error, mediaplayer is in the ERROR state).
I tested on Google PIXEL XL and Nexus 6P and I am getting this problem for Nexus 6P.

Play Audio on Android

Answers to many questions about this theme doesn't help me! It's not the problem that audio needs to be started first by a click or any other type of action.
I want to Play a number of different short mp3's on my website. The best approach I've found is the following. It works on Internet Explorer and Chrome (other Desktop browsers not tested) and on mobile devices with iOS. But not on Android.
In my html I initialize an audio device:
<audio id="mp3play" src=""></audio>
It's only for defining the name "mp3play".
In the header of the html I have the following javascript:
<SCRIPT language=JavaScript>
<!--
function play(name) {
var oAudio = document.getElementById("mp3play");
oAudio.stop;
oAudio.src = name;
oAudio.play();
}
//-->
Now I can invoke the player with the following link:
<a href="javascript:play('stuff/voc/WAVvow/011001.MP3');"
This works fine, even on Android.
But for special requirements I do not use filenames for mp3's. I've made a Perl script to deliver the pm3 data depending on a computation. For this I use the following link:
<a href="javascript:play('../cgi-bin/playmp3.pl?185004');"
This Perl code "playmp3.pl" sends a header and then the complete mp3 data:
($entry[0] has a pointer to the desired data, $entry[1] the length)
open(DAT, "<../wbtde/DictData/dv8.dat");
binmode DAT;
seek(DAT, $entry[0], 0);
read(DAT, $mp3, $entry[1]); # Lesen des Eintrages
close DAT;
print "Content-type: audio/mpeg\n\n";
print $mp3;
Also this works fine on IE, Chrome and iOS browsers, but not on Android.
I can invoke the script also directly with
www.mysite.com/cgi-bin/playmp3.pl?185004
Also this is working fine on IE, Chrome and iOS browser, but not on Android. Android tells me it can not play this type of content. But with content type audio/mpeg3 it's also not playing.
This is the Android error log when I tap one link only:
D/CDX_Player( 2402): >>>>>>>> CedarX Player Version: 00010707
I/CedarPlayerWrapper( 2402): setDataSource('http://www.example.com/cgi-bin/playmp3.pl?062013')
I/ChromiumHTTPDataSource( 2402): connect to http://www.example.com/cgi-bin/playmp3.pl?062013 #0
W/MediaPlayer( 967): info/warning (701, 0)
I/MediaPlayer( 967): Info (701,0)
D/sft_http_stream( 2402): reset stream
I/NuCachedSource2( 2402): ERROR_END_OF_STREAM
W/demux_http( 2402): unknown file format!
E/demux_http( 2402): open error, destroy stream handle
E/DemuxSftNetwork_Component( 2402): cedar demuxer open error
E/CedarXPlayer( 2402): CedarXPlayer:prepare error!
E/MediaPlayer( 967): error (1, -2147483648)
E/MediaPlayer( 967): Error (1,-2147483648)
I/CDX_Player( 2402): cancel prepare!
D/CDX_Player( 2402): >>>>>>>> CedarX Player Version: 00010707
I/CedarPlayerWrapper( 2402): setDataSource('http://www.example.com/cgi-bin/playmp3.pl?062013')
W/MediaPlayer( 967): info/warning (701, 0)
I/ChromiumHTTPDataSource( 2402): connect to http://www.example.com/cgi-bin/playmp3.pl?062013 #0
I/MediaPlayer( 967): Info (701,0)
D/sft_http_stream( 2402): reset stream
I/NuCachedSource2( 2402): ERROR_END_OF_STREAM
W/demux_http( 2402): unknown file format!
E/demux_http( 2402): open error, destroy stream handle
E/DemuxSftNetwork_Component( 2402): cedar demuxer open error
E/CedarXPlayer( 2402): CedarXPlayer:prepare error!
E/MediaPlayer( 967): error (1, -2147483648)
E/MediaPlayer( 967): Error (1,-2147483648)
I/CDX_Player( 2402): cancel prepare!
Another try:
I've saved the output from Perl script to a file with the name "test.MP3". Then I've prepared a link in my html as
<a href="javascript:play('stuff/test.MP3');"
This works on Android! So I can assume that the output of the Perl script is correct.
Is it a question of content type?
Is it a question of the filename (.pl instead of mp3)?
It is the Filename!
Fortunately Android accepts the addition ".mp3" to the Perl call:
www.mysite.com/cgi-bin/playmp3.pl?185004.mp3
I've changed the Perl script to remove that addition and now it works on all platforms.

How to play Video from application cache in android

I want to play video file from android cache folder using the following code :
String cacheDir = getApplicationContext().getCacheDir().getAbsolutePath();
File outFile = new File(cacheDir, "intro.mp4");
vvIntro.setVideoPath(cacheDir+"/intro");
vvIntro.start();
But I got error :
07-05 20:14:21.896: E/MediaPlayer(1251): error (1, -2147483648)
07-05 20:14:21.928: I/Choreographer(1251): Skipped 79 frames! The application may be doing too much work on its main thread.
07-05 20:14:22.186: D/gralloc_goldfish(1251): Emulator without GPU emulation detected.
07-05 20:14:22.496: E/MediaPlayer(1251): Error (1,-2147483648)
07-05 20:14:22.496: D/VideoView(1251): Error: 1,-2147483648
where the file is already exists and the required persimmon as show below :
You create a File object pointing to your MP4 file, then totally ignore that File object and provide an invalid path to vvIntro. Instead, try:
File outFile = new File(getCacheDir(), "yourVideoName.mp4");
vvIntro.setVideoPath(outFile.getAbsolutePath());
vvIntro.start();
and see if that helps.
You can just use my simple library AndroidVideoCache. It allows stream and cache video simultaneously.
you can set Uri :
Uri uri = Uri.parse(getApplicationContext().getCacheDir()+"/video.mp4") ;
videoView.setVideoURI(uri);
videoView.start();

Categories

Resources