Reputation: 40416
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
Upvotes: 2
Views: 6522
Reputation: 21
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)
Upvotes: 0
Reputation: 57316
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
Upvotes: 1
Reputation: 13242
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.
Upvotes: 2
Reputation: 1530
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!
Upvotes: 0