Problem with playing Video file.

All your problems with Audio, Video and Images.

Problem with playing Video file.

Postby John » Fri Oct 16, 2009 9:19 am

Hi All,

I am just trying to play a video from a raw folder available in my project resource by using the following simple code snippet provided by Android developers website.

public void onCreate(Bundle savedInstanceState) {

MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.sample); // sample: it is a .m4v file.


But when i run my code, it plays only the sound, i didn't see video player or video. Only sound is coming. May i know what should be the problem and how to resolve this issue?
I even tried adding Prepare() function, still observing the same problem.

Note: I'm trying on Android OS 1.5 HTC T-mobile handset.

Can someone came across this please provide me your suggestions?

Posts: 7
Joined: Fri Oct 16, 2009 8:36 am


Postby chimaera » Wed Nov 04, 2009 1:28 am

I believe your code is for audio playback only.

You have to declare a surface holder for video playback:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mMediaPlayer.setDisplay(holder);
Parsed in 0.032 seconds, using GeSHi

Check the MediaPlayerDemo. It's in the Api demos
Junior Developer
Junior Developer
Posts: 22
Joined: Fri Jun 19, 2009 1:42 am


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 15 guests