I have prepared a code to just play a simple mp4 file from my res folder. The coding is something like this:
public class VideoPlayer extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video);
VideoView video = (VideoView)findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://company.software.myapp/"
+ R.raw.myvideo);
MediaController mc = new MediaController(this);
video.setMediaController(mc);
video.setVideoURI(uri);
//video.requestFocus();
video.start();
}
}
Now though there is no error in playing. The activity automatically generates a dialog saying "sorry this video cannot be played", but I can hear the audio and it plays till end. What is the problem?
Thanx a lot commonsware.com… but i found the solution to the problem… And astonishingly its the PC processor which is the culprit… I checked n a higher configuration and guess wat… it worked perfectly fine… though sometimes if we do some processing in the background the dialog box does come up but on clicking ok it starts playing the video after some time…
But i confirm that this technique of playing file from resource is ok as far as i know…
sorry to waste ur precious time in a mundane hardware problem… but hope it’ll be useful for other people who get this problem…