Video player error playing local videos - android

I'm trying to create a activity with a Video Player.
The problem is that in some devices (ex. Android 4.0.4) when I try to play local video the VideoView shows LogCat error :
MediaPlayer(6757): Error (1,-2147483648)
And on screen:
"Cannot play video. Sorry, this video cannot be played"
The videos be recorded with MediaRecorder and this is the config of MediaRecorder
public boolean initRecorder(){
myRecorder = new MediaRecorder();
myRecorder.setCamera(myCamera);
myRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
myRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
myRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
myRecorder.setOutputFile(getVideoFilePath()); //videopath.mp4
myRecorder.setVideoSize(size.width, size.height);
myRecorder.setPreviewDisplay(mySurfaceHolder.getSurface());
if(prepareRecorder()) return true;
else return false;
}
And played with VideoView like this:
VideoView vidDisplay = (VideoView) viewLayout.findViewById(R.id.vidDisplay);
Uri uri = Uri.parse(_imagePaths.get(position));
vidDisplay.setVideoURI(uri);
vidDisplay.setMediaController(new MediaController(_activity));
vidDisplay.requestFocus();
vidDisplay.start();
EDIT:
The problem is related to the user permissions of the video. Is there a way to create aguna videos with MediaRecorder with read permissions for everyone?
I tried to open the file and then make setReadable(true) but this not work
Can someone help me?
Thanks

Related

android videoview error 1, -2147483648

I am getting error while playing video from asset folder and raw folder.
MediaPlayer error (1, -2147483648)
VideoView error 1, -2147483648.
I tried from asset folder as.
private String SrcPath = "file:///android_asset/aaa.mp4"; //also tried aaaa.mp3
VideoView vv = (VideoView)findViewById(R.id.videoView1);
vv.setVideoPath(SrcPath);
MediaController controller = new MediaController(this);
controller.setAnchorView(vv);
vv.setMediaController(controller);
vv.requestFocus();
vv.start();
and for raw folder i used URI as :
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/aaa.mp4");
vv.setVideoURI(video);
I got the same error message in both cases.
You can use software like avinaptic2 to get the video encoding information and make sure it matches the supported media formats in android.
A common problem I find is that videos are encoded with the wrong profiling. H.264 videos need to be encoded with Baseline level 3 or under to be played without errors or artifacts in Android.
I found the solution as I am able to play video on virtual device.
I replaced the line
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/aaa.mp4");
with
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/"+R.raw.aaa);
And its working
Using R.raw works fine but in some cases I still get the same error. Fortunately I found the solution to my problem: I had to call videoView.start() inside onPrepare().
You can check the correct answer here:
Android: 'Can't play this video'; MediaPlayer & VideoView Error 1 -38

Android Sorry, this video cannot be played

I'm using VideoPlayer in my app. It play everything fine but when I want to scroll on the media player's bar, usually it gives me the error : Sorry, this video cannot be played. and I have to restart the video to watch it again. All I found is if I stop the video and scroll the bar it will be fine. I just wonder how can I fix this problem ? how can I access to media player's bar. Hens I can pause the video onClick. My code:
MediaController mediaController = new MediaController(
rootView.getContext());
mediaController.setAnchorView(video);
Uri uri = Uri.parse(passVideo.file_link);
video.setMediaController(mediaController);
video.setVideoURI(uri);
video.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
mProgress.setVisibility(View.INVISIBLE);
video.requestFocus();
video.start();
}
});
Many people get this error like you,
Bugs :
Sorry this video is not valid for streaming to this device.
Sorry, this video can not be played.
You can find out at Sorry, this video is not valid for streaming to this device in Http streaming android
Thanks,

Android VideoView Cannot play video mp4

I used the Android VideoView to play a video file via HTTP. My problem is my phone prompts "Cannot play video Sorry, this video cannot be played." when playing a mp4 file from HTTP. But it is ok when playing another mp4 video file.
When used in a newer phone, like Samsung Galaxy S, my program can play both mp4 video file from HTTP successfully.
My phone:
Samsung GT-S5830
Android version: 2.3.4
Display: 320x480.
Video file 1 (OK):
Video Codec: H.264
Resolution: 640x360
Others: 16:9, 340kbps, 29.92fps
Audio Codec: AAC, 44kHz 96kbps Stereo.
Video file 2 (Fail):
Video Codec: H.264
Resolution: 640x360
Others: 16:9, 993kbps, 25fps
Audio Codec: AAC 44kHz 125kbps Stereo.
Below is my code that hardcoded to play the video file 1 successfully.
public class VideoPlayActivity extends Activity {
VideoView vv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
vv = new VideoView(this);
RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
param1.addRule(RelativeLayout.CENTER_IN_PARENT);
vv.setOnErrorListener(new OnErrorListener() {
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.d("Dbg", "OnErrorListener: onError: " + what + ", " + extra);
return false;
}
});
RelativeLayout layout = new RelativeLayout(this);
layout.addView(vv, param1);
setContentView(layout);
playContent();
}
private void playContent() {
String path = "http://rmcdn.2mdn.net/MotifFiles/html/1248596/android_1330378998288.mp4";
vv.setVideoPath(path);
vv.requestFocus();
vv.start();
}
}
The error log when playing video file 2 is as below:
11-19 17:49:30.119: I/VideoView(16860): start()
11-19 17:49:30.139: E/MediaPlayer(16860): error (1, -2147483648)
11-19 17:49:30.149: E/MediaPlayer(16860): Error (1,-2147483648)
11-19 17:49:30.149: D/VideoView(16860): Error: 1,-2147483648
11-19 17:49:30.149: D/Dbg(16860): OnErrorListener: onError: 1, -2147483648
It is noted that I tried to install the MX player and downloaded the both video file into my phone's SD card. The MX player can play both video files successfully.
So, can anyone help me to answer the questions below:
Why my program cannot play the video file 2 on my phone?
How can I play the video file 2 on my phone?
Thank you for your advice.
Thanks for the answer from Android MediaPlayer error (1, -2147483648).
I found the video file 2 was encoded in H.264 Main Profile, that my mobile phone cannot be played. Android Supported Media Format suggests H.264 in Baseline Profile. So after converting the video to Baseline Profile, it can be played on my phone.

how to know video format or type

i am getting list of video files from web services and playing in Videoview . Some video getting played .for example mp4. While some video are not for example .mov file.So I want to check the format of video so that i can handle in error listner in android. My question is how to know format another question-I am playing the video in videoview and doing manually streaming. I am buffering some amount and then playing the video simulataneously. video is getting played but after some time it raising warning like media cannot be played .I think that because of unavailibilty of media in file it saying like that because when total amount of video is present in file then it playing total video without warning . My 2 question is- what is your opinion .what is the reason for this .how can i correct it
Intent intent=anyPlayer(urlstring);
startactivity(intent);
public static Intent anyPlayer(String DestAddr)
{
Uri uri = Uri.parse(DestAddr.toString());
Intent i = new Intent("android.intent.action.VIEW");
i.setDataAndType(uri, "video/*");
return i;
}

VideoView on Archos 5 (Android 1.6) doesn't work

I'm developing an app for the Archos 5 Internet Tablet. (With Android 1.6)
I want to start a video in a VideoView within my app. On my Android emulator the following code works fine but on my Archos 5 I always get an error:
Cannot play video
Sorry, this video cannot be played.
//get current window information, and set format, set it up differently, if you need some special effects
getWindow().setFormat(PixelFormat.TRANSLUCENT);
//the VideoView will hold the video
VideoView videoHolder = (VideoView) findViewById(R.id.VideoView01);
//MediaController is the ui control hovering above the video (just like in the default youtube player).
videoHolder.setMediaController(new MediaController(this));
//assing a video file to the video holder
videoHolder.setVideoURI(Uri.parse("android.resource://mypackage/" + R.raw.testmovie));
//get focus, before playing the video.
videoHolder.requestFocus();
if(autoplay){
videoHolder.start();
}
Is there a way to run a VideoView on a archos 5?
I also tried to play the movie with the archos player. With the following code I get the error: "Cannot find the media file!".
String ACTION_LAUNCH_AVOS = "android.intent.action.LAUNCH_AVOS";
String avosCommand = "ACTION:video_play,url=videoentries:Video/testmovie.wmv,etype=resume";
final Intent startAvos = new Intent(ACTION_LAUNCH_AVOS,Uri.parse(avosCommand));
startAvos.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity(startAvos);
I put the video in the Video folder of the Archos. The video runs when I open it with the file browser.
I always get the error "Cannot find the media file!", no matter what url I use.
Is there a certain folder where I have to put the video so that it can be found? And how do I get the url to that certain folder?
It would be great if you could help me!
Thanks and BR,
Thomas

Categories

Resources