Android: 'Can't play this video'; MediaPlayer & VideoView Error 1 -38 - android

I tried to play a video with the code below. However, I get the classic error of 'Can't play this video' pop-up at run time. I did my due diligence in searching the android literature and looking through other people's questions, but I can't seem to find the problem a) because no where in the documentation can I find the error code (1 ,-38) for MediaPlayer and b) my video meets the specifications required for android media formats (h.264 and MPEG-4). If anyone can help point me in the right direction I'd really appreciate it! Thanks
private void startVideo() {
Log.v(TAG, "videoUrl = " + mVideoUrl);
Uri uri = Uri.parse(mVideoUrl);
mVideo = (VideoView) getView().findViewById(R.id.preview_videoView);
MediaController mediaController = new MediaController(getActivity());
mediaController.setAnchorView(mVideo);
mVideo.setMediaController(mediaController);
mVideo.setVideoURI(uri);
mVideo.start();
}
These are the logs
10-07 21:08:38.529 9986-9986/com.trainwithtanya.hiitandroid V/﹕ videoUrl = http://files.parsetfss.com/2bb9a4a0-9f35-4124-a634-d2fa7f8b165e/tfss-ca535209-4b4c-4022-95b8-8f011ed41daf-High%20Knees.mp4
10-07 21:08:38.579 9986-10011/com.trainwithtanya.hiitandroid W/EGL_emulation﹕ eglSurfaceAttrib not implemented
10-07 21:08:38.579 9986-10011/com.trainwithtanya.hiitandroid W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa5245c20, error=EGL_SUCCESS
10-07 21:08:38.609 9986-9986/com.trainwithtanya.hiitandroid D/MediaPlayer﹕ Couldn't open file on client side, trying server side
10-07 21:08:39.582 9986-9986/com.trainwithtanya.hiitandroid D/MediaPlayer﹕ getMetadata
10-07 21:08:39.637 9986-9999/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ error (1, -38)
10-07 21:08:39.637 9986-9986/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ Error (1,-38)
10-07 21:08:39.637 9986-9986/com.trainwithtanya.hiitandroid D/VideoView﹕ Error: 1,-38
10-07 21:08:39.650 9986-10000/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ error (1, -38)
10-07 21:08:39.702 9986-9986/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ Error (1,-38)
10-07 21:08:39.702 9986-9986/com.trainwithtanya.hiitandroid D/VideoView﹕ Error: 1,-38
Here is the video format
http://i288.photobucket.com/albums/ll185/akhan007/mediaType_zpsjfvfdpto.png

I think, you need call mVideo.start(); inside onPrepare
mVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mVideo.start();
}
});

Related

Android weird black videoview + errors on real world device, not in emulator

So, I have an app that I'm trying to get to loop a bunch of video portraits at the bottom. It works perfectly on the emulator (Android 4.1) and seemed to work on my phone (7.1).
On the device I need to deploy the app to (an old android 4.0 TV box) the videos appear black, or start showing something and then go to black shortly after.
I tried an emulator of 4.0 and it seems to be doing the same thing, but I can't figure out why and searches for the error codes it's shooting out don't pull up anything.
It loops through all the portraits and creates video views like this:
`
VideoView video = new VideoView(context);
boolean failure = false;
Log.d("videoPlayer", "Playing video: " + Environment.getExternalStorageDirectory()+"/reviews/" + localPortraits[i]);
video.setVideoPath(Environment.getExternalStorageDirectory()+"/reviews/" + localPortraits[i]);
video.setOnErrorListener(new MediaPlayer.OnErrorListener(){#Override
public boolean onError(MediaPlayer nmp, int what, int extra){
Log.d("MediaPlayer", "CAUGHT ERROR. ReDownload");
badMovie(nmp.toString());
return true;
}
});
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mp.start();
mp.setLooping(true);
}
});
frame.addView(video);
}`
And again, running in the 4.1 emulator it works beautifully. When I put it on the 4.0 TV or 4.0 emulator, it shoots out this:
W/MediaPlayer: info/warning (8004, 0)
I/MediaPlayer: Info (8004,0)
W/MediaPlayer: info/warning (8004, 0)
I/MediaPlayer: Info (8004,0)
W/MediaPlayer: info/warning (8004, 0)
I/MediaPlayer: Info (8004,0)
I/VideoView: MediaPlayer:AMLOGIC_PLAYER Prepared
D/MediaPlayer: getMetadata
I/VideoView: Layout changed,left=3 top=3 right=80 bottom=140
I/VideoView: Layout changed,oldLeft=3 oldTop=3 oldRight=81 oldBottom=140
I/VideoView: .left=3.top=3.right=80.bottom=140.oldLeft=3.oldTop=3.oldRight=81.oldBottom=140.Rotation=0
I/VideoView: MediaPlayer:AMLOGIC_PLAYER Prepared
D/MediaPlayer: getMetadata
E/MediaPlayer: error (1, -33554484)
E/MediaPlayer: error (1, -1)
I/VideoView: MediaPlayer:AMLOGIC_PLAYER Prepared
D/MediaPlayer: getMetadata
E/MediaPlayer: error (1, -33554484)
E/MediaPlayer: error (1, -1)
Plus a ton more along the same lines.
What am I doing wrong that it won't run on Android 4.0?

Android MediaPlayer error (1, -19)

I am working on an app in which an audio file (boo.wav) is being played. The audio does however not play and generates some error output.
When trying to execute the following line:
MediaPlayer.create(this, R.raw.boo).start();
I get the following errors:
E/MediaPlayer﹕ Should have subtitle controller already set
E/MediaPlayer﹕ error (1, -19)
E/MediaPlayer﹕ Should have subtitle controller already set
E/MediaPlayer﹕ Error (1,-19)
Can someone point me in a general direction as to what I am doing wrong?

Android videoView gives me Alert "Sorry,This video cannot be played"?

My Code::
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri
.parse("www.logisticinfotech.com/client/Malasiya Cup/movie.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
Error::Sorry,This video cannot be played.
Logcat::
01-03 20:19:14.044: DEBUG/AndroidRuntime(454): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
01-03 20:19:14.044: DEBUG/AndroidRuntime(454): CheckJNI is ON
01-03 20:19:14.224: DEBUG/AndroidRuntime(454): --- registering native functions ---
01-03 20:19:14.874: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.logistic.videoview/.MainActivity }
01-03 20:19:15.014: DEBUG/AndroidRuntime(454): Shutting down VM
01-03 20:19:15.044: DEBUG/dalvikvm(454): Debugger has detached; object registry had 1 entries
01-03 20:19:15.134: INFO/AndroidRuntime(454): NOTE: attach of thread 'Binder Thread #3' failed
01-03 20:19:15.784: INFO/StagefrightPlayer(34): setDataSource('www.logisticinfotech.com/client/Malasiya Cup/movie.mp4')
01-03 20:19:15.805: ERROR/MediaPlayer(420): error (1, -2147483648)
01-03 20:19:15.834: INFO/ActivityManager(59): Displayed activity com.logistic.videoview/.MainActivity: 821 ms (total 821 ms)
01-03 20:19:15.885: ERROR/MediaPlayer(420): Error (1,-2147483648)
01-03 20:19:15.885: DEBUG/VideoView(420): Error: 1,-2147483648
I'd recommend you have a look at Android's overview of supported media formats. This site covers everything from the first versions of Android to the latest:
Android Supported Media Formats
I'm guessing you're trying to include a video in your application, and that it needs to work on all devices, so I'd suggest you go ahead and try to encode a video with a profile similar to the SD (High quality) listed on the above mentioned site.
There are plenty of free video converters available that you can use for encoding the video - one of them could be Freemake Video Converter.
To expand further on my comment, I had fought a lot with different encodings/formats/etc until I got the one that worked on all android devices (at least all that I tested). Using ffmpeg, here's what finally worked:
/usr/bin/ffmpeg -i inputfile.ext -y -s 320x240 -vcodec libx264 -vpre medium -vpre baseline -acodec libfaac output.mp4
I have the same problem , I just figured out that it cames from the video format and encoding. But I didn't really fing the combination thet works on all devices.
thanks for give the answer if you find it!
i had d same issue
and i resolved by adding a delay of 250ms. actually the error occurs when we try to capture and play immediately. At that time, the engine is not yet ready to play (coz it hasnt reached End of streami.e. hasnt read the video completely)

android media player - PVMFFailure on mp3 http radio stream

I want to play mp3 radio stream using Android MediaPlayer via http protocol. From time to time [1 playing of 5 - that is actually quite often] I receive PVMFFailure like this:
02-23 02:05:23.503: ERROR/PlayerDriver(91): Command PLAYER_INIT completed with an error or info PVMFFailure
02-23 02:05:23.503: ERROR/MediaPlayer(2111): error (1, -1)
02-23 02:05:23.533: ERROR/MediaPlayer(2111): stop called in state 0
02-23 02:05:23.533: ERROR/MediaPlayer(2111): error (-38, 0)
There is no solution here or on google, so please if you do know how to debug this, please help :)
Here is my code for player:
//start
MediaPlayer player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource(address);
player.prepare();
player.start();
//stop
player.stop();
player.reset();
I`m using Android 2.2 API. Thanks!
You should use player.prepareAsync(); instead player.prepare();.

Android Shoutcast: Want help to play ShoutCast Streaming in 1.6

My application plays ShoutCast Streaming and the target OS is 1.6 and above. I have applied some code from NPR application with some modification.
Here is the code
mediaPlayer = new MediaPlayer();
mediaPlayer.reset();
mediaPlayer.setDataSource(url);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
// Log.d(LOG_TAG, "Preparing: " + playUrl);
mediaPlayer.prepareAsync();
mediaPlayer.start();`
The code doesnot play anything on simulator or device(Testing in Samsung Galaxy with 2.1).
Here is the LogCat message.
About to play http://88.191.81.31:8206
12-08 14:16:42.229: WARN/MediaPlayer(5520): info/warning (1, 26)
12-08 14:16:42.239: ERROR/PlayerDriver(1870): Command PLAYER_INIT completed with an error or info PVMFFailure
12-08 14:16:42.239: ERROR/MediaPlayer(5520): error (1, -1)
12-08 14:16:42.239: WARN/PlayerDriver(1870): PVMFInfoErrorHandlingComplete
12-08 14:16:42.259: ERROR/MediaPlayer(5520): start called in state 0
12-08 14:16:42.259: ERROR/MediaPlayer(5520): error (-38, 0)
12-08 14:16:42.299: INFO/MediaPlayer(5520): Info (1,26)
12-08 14:16:42.299: ERROR/MediaPlayer(5520): Error (1,-1)
12-08 14:16:42.304: ERROR/MediaPlayer(5520): Error (-38,0)
Here is the question. 1. Can you tell me whats happening in device? 2. How to solve this error?.
You are calling start() too soon. Javadocs of MediaPlayer explain it (look at the picture):
Either you have to call prepare() before you call start(), or
You call prepareAsync() and wait for OnPreparedListener.onPrepared() to be called, then (possibly inside this method) call start().
Updated:
Shoutcast streams are nativelly supported only on 2.2. For earlier versions you must create local proxy that changes the response protocol from ICY (shoutcast) to HTTP, which the
mediaplayer will support. Take a look at this:
http://code.google.com/p/npr-android-app/source/browse/trunk/Npr/src/org/npr/android/news/StreamProxy.java
This has previously been discussed:
Listen to a shoutcast with Android

Categories

Resources