Android media player does not work

I am trying to develop an application in which there are many videos embedded in it, and I would like to name Android Media Player with video on the VideoView object. However, I get these strange errors:

  • I / MediaPlayer (2874): Information (1.26)
  • E / MediaPlayer (2874): error (-4, -4)
  • D / VideoView (2874): Error: -4, -4

when I try to play mp4 video or other 3gp video that is not being recorded from my phone. My code looks something like this:

import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.MediaController; import android.widget.VideoView; public class PlayTest2 extends Activity{ private MediaController ctlr; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.test2); try { VideoView video = (VideoView) findViewById(R.id.test2); // Load and start the movie video.setVideoPath("android.resource://com.example.child.protector/raw/output"); ctlr=new MediaController(this); ctlr.setMediaPlayer(video); video.setMediaController(ctlr); video.start(); //video.requestFocus();//this line is new } catch (Exception e) { Log.e("---------- this is my app --------", "error: " + e.getMessage(), e); } } } 

and my layout is something like:

 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <VideoView android:id="@+id/test2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" /> </FrameLayout> 

Is there something wrong with my code?

and I know that my file is there and that's it. I ran this code with a sample 3GP video and it worked fine (but I recorded the video from my phone and copied it to my computer and then packed it back into my application under the / res / raw folder in Eclipse). However, the problem is that for some reason, my media player only plays certain 3GPP files. If I try to convert MP4 to 3GP using MobileMediaConverter, it plays on my laptop, but not in this application. Also note that if I open the video as a file (in other words, by calling the default player on my Samsung Galaxy S phone), it works fine (this means that my phone has features). Therefore, I am interested in:

  • Is this something wrong with the code?
  • Is it rather a mp4-3gp error conversion?

Any help would be greatly appreciated. Thank!!

+2
android android-mediaplayer android-videoview
May 28 '11 at 3:44
source share
1 answer

The problem was that certain converters (with different settings) would create a video file that did not start on my Samsung Galaxy Android Android device. the code here is generic, but I think the codec should be something like H.264 when doing the video conversion. Then I downloaded about 5 video converters, and 2 of them will actually make 3GPP what my device can play. therefore, if anyone else has this problem, I would recommend trying a bunch of video converters with different codec / sound settings. I ended up being able to find one that worked in my particular case

+1
Nov 23 2018-11-11T00:
source share



All Articles