I try to play a video in my application, and I get I can not play this video . I came across many topics regarding this. They asked to start the video as soon as the player is prepared. I'm doing the same thing. But I could not understand the problem. Please find my code below.
public class Video extends Activity implements MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener { public VideoView vidPlayer; @Override protected void onCreate(Bundle savedInstanceState) { setup(); activateVideoPlayer(); } public void setup() { setContentView(R.layout.step_video); vidPlayer = (VideoView) findViewById(R.id.videoPlayer); String playableUrl = "http://teststreaming7v.s3.amazonaws.com/public/7515/1374782317346-beagle_puppy_howl_640x360_448_main.mp4"; } @Override public void onPrepared(final MediaPlayer mediaPlayer) { mediaPlayer.setLooping(false); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); startPlayer(); videoLoaded = true; mediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() { // show updated information about the buffering progress public void onBufferingUpdate(MediaPlayer mp, int percent) { Log.d(this.getClass().getName(), "percent: " + percent); } }); mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mediaPlayer) { progress.setProgress(100); setResult(Activity.RESULT_OK); finish(); } }); readyToPlay = true; } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } @Override public void onPause() { super.onPause(); pausePlayer(); } @Override public void finish() { super.finish(); overridePendingTransition(R.anim.engagement_fade_in, R.anim.engagement_fade_out); } @Override public void onBackPressed() { isGoingBack = true; setResult(Activity.RESULT_CANCELED); finish(); } @Override public boolean onError(MediaPlayer mediaPlayer, int i, int i1) { JLogger.getInstance(this).log("Video Player Error!!" + Integer.toString(i) + " / " + Integer.toString(i1)); return false; } public void startPlayer() { isPaused = false; vidPlayer.start(); } public void pausePlayer() { isPaused = true; vidPlayer.pause(); } private void activateVideoPlayer() { vidPlayer.setOnErrorListener(this); vidPlayer.setOnPreparedListener(this); btnPlay.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (vidPlayer.isPlaying()) { pausePlayer(); } else { startPlayer(); } } }); vidPlayer.setVideoURI(Uri.parse(playableUrl)); vidPlayer.seekTo(step.resumePosition); } }
The device I am using - Motorola Atrix - Android 4.1.2 - is unlocked. I also tried on other devices such as Nexus 4, 5 and Samasung Tab 2. His work there is great.
This is my journal:
12-16 13:42:35.184 4427-4427/? D/MediaPlayer﹕ Couldn't open file on client side,trying server side 12-16 13:42:35.184 1417-1830/? I/AwesomePlayer﹕ setDataSource_l('http://teststreaming7v.s3.amazonaws.com/public/7515/1374782317346-beagle_puppy_howl_640x360_448_main.mp4') 12-16 13:42:35.184 1417-5481/? V/ChromiumHTTPDataSource﹕ connect on behalf of uid 10069 12-16 13:42:35.184 1417-5481/? I/ChromiumHTTPDataSource﹕ connect to http://teststreaming7v.s3.amazonaws.com/public/7515/1374782317346-beagle_puppy_howl_640x360_448_main.mp4 @0 12-16 13:42:35.684 1424-1673/? I/﹕ odm_disp_esd_thread is running(467) state=1 12-16 13:42:35.684 1417-5481/? W/WVMExtractor﹕ Failed to open libwvm.so 12-16 13:42:36.184 4547-4576/? W/GAV2﹕ Thread[GAThread,5,main]: Exception sending hit: HttpHostConnectException 12-16 13:42:36.184 4547-4576/? W/GAV2﹕ Thread[GAThread,5,main]: Connection to https://ssl.google-analytics.com refused 12-16 13:42:36.184 1417-5481/? E/OMXCodec﹕ failed to allocate node OMX.Nvidia.h264.decode 12-16 13:42:36.184 1417-5481/? E/OMXCodec﹕ failed to allocate node OMX.google.h264.decode 12-16 13:42:36.184 1417-5481/? I/OMXCodec﹕ [OMX.google.h264.decoder] AVC profile = 77 (Main), level = 22 12-16 13:42:36.184 1417-5481/? I/OMXCodec﹕ [OMX.google.h264.decoder] video dimensions are 320 x 240 12-16 13:42:36.184 1417-5481/? I/OMXCodec﹕ [OMX.google.h264.decoder] Crop rect is 320 x 240 @ (0, 0) 12-16 13:42:37.184 4427-4427/? D/MediaPlayer﹕ getMetadata 12-16 13:42:37.184 4427-4427/? D/VideoSample﹕ onPrepared() method 12-16 13:42:37.184 1417-1687/? D/AudioHardwareMot﹕ bufSize = 8192 12-16 13:42:37.184 1417-5484/? E/SoftAVC﹕ Decoder failed: -2 12-16 13:42:37.184 1417-5485/? E/OMXCodec﹕ [OMX.google.h264.decoder] ERROR(0x80001001, -1007) 12-16 13:42:37.184 1417-5486/? I/SoftAAC2﹕ Reconfiguring decoder: 44100 Hz, 2 channels 12-16 13:42:37.184 4427-4449/? E/MediaPlayer﹕ error (1, -2147483648) 12-16 13:42:37.184 1692-2165/? D/dalvikvm﹕ GC_EXPLICIT freed 113K, 39% free 8906K/14467K, paused 3ms+5ms, total 93ms 12-16 13:42:37.184 4427-4427/? E/MediaPlayer﹕ start called in state 0 12-16 13:42:37.184 4427-4427/? E/MediaPlayer﹕ error (-38, 0) 12-16 13:42:37.184 4427-4427/? E/MediaPlayer﹕ Error (1,-2147483648) 12-16 13:42:37.184 4427-4427/? D/VideoView﹕ Error: 1,-2147483648 12-16 13:42:37.184 4427-4427/? D/VideoSample﹕ VideoSample: Video Player Error!!1 / -2147483648 12-16 13:42:37.184 4427-4427/? D/VideoSample﹕ VideoSample: Get url: http://teststreaming7v.s3.amazonaws.com/public/7515/1374782317346-beagle_puppy_howl_640x360_448_main.mp4 12-16 13:42:37.184 4427-4427/? E/MediaPlayer﹕ Error (-38,0) 12-16 13:42:37.184 4427-4427/? D/VideoView﹕ Error: -38,0 12-16 13:42:37.184 4427-4427/? D/VideoSample﹕ VideoSample: Video Player Error!!-38 / 0 12-16 13:42:37.184 4427-4427/? D/VideoSample﹕ VideoSample: Get url: http://teststreaming7v.s3.amazonaws.com/public/7515/1374782317346-beagle_puppy_howl_640x360_448_main.mp4`
EDIT 1
I tried playing the following two .mp4 files, of which the first was playing, and the second was not.
Video Properties 1
URL: Video URL
Video Bitrate: 179.9 Kbps
Audio Channels: Stereo

Video Properties 2 URL: Video URL
Video Bitrate: 446.9 Kbps
Audio Channels: Mono
