MediaPlayer not running - just blank screen

All your problems with Audio, Video and Images.

MediaPlayer not running - just blank screen

Postby nithin.warier » Thu Mar 05, 2009 8:51 am

hi,
I tried a simple mediaplayer application, just to run a .3gp file.
First, i put the .3gp file in "Raw" folder and tried to run, but
nothing is displaying, just blank screen only.... please guide me,
where i am going wrong. I dont have any xml file, is it needed ??
heres the code, which i am trying
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
public class MonsterEntry extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MediaPlayer mediaplayer = MediaPlayer.create(this, R.raw.monster);
mediaplayer.start();
}
}

Thanks
Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Top

Postby nithin.warier » Thu Mar 05, 2009 10:45 am

Now i am trying with
this code...
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.MediaController.MediaPlayerControl;
public class Monster extends Activity implements
SurfaceHolder.Callback, MediaPlayer.OnPreparedListener {
SurfaceView mPreview;
SurfaceHolder holder;
MediaPlayer mediaplayer;
int mVideoWidth,mVideoHeight;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bushentry);
mPreview = (SurfaceView)findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mediaplayer = MediaPlayer.create(this, R.raw.monster);
mediaplayer.start();
mediaplayer.setDisplay(holder);
mediaplayer.setOnPreparedListener(this);
}
public void surfaceChanged(SurfaceHolder holder, int format, int
width,
int height) {
}
public void surfaceCreated(SurfaceHolder holder1) {
mVideoWidth = mediaplayer.getVideoWidth();
mVideoHeight = mediaplayer.getVideoHeight();
if (mVideoWidth != 0 && mVideoHeight != 0) {
holder.setFixedSize(mVideoWidth, mVideoHeight);
mediaplayer.start();
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
}
public void onPrepared(MediaPlayer mp) {
mVideoWidth = mediaplayer.getVideoWidth();
mVideoHeight = mediaplayer.getVideoHeight();
if (mVideoWidth != 0 && mVideoHeight != 0) {
holder.setFixedSize(mVideoWidth, mVideoHeight);
mediaplayer.start();
}
}
}

Still, the same problem, no error, but blank screen, any idea please..

Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Postby nithin.warier » Fri Mar 06, 2009 10:10 am

got it at last...


Thanks
Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Postby MrSnowflake » Fri Mar 06, 2009 11:14 am

You might wanna explain what the sollution was.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby nithin.warier » Fri Mar 06, 2009 1:04 pm

The solution was,

I have to do the media player initialization in onSurfaceCreated(), we have to wait until Surface is created.

Earlier i done the mediaplayer initialization in onCreate()....

Thanks
Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Postby guruk » Sun Mar 08, 2009 8:19 pm

very interesting. is it possible you give the full source in a zip
i am just looking for a simple solution to start the mediaplayer

i have a video on: http://192.168.0.179/2.mp4

when i just call:

Uri myUrl = Uri.parse("http://192.168.0.179/2.mp4");
Intent intent = new Intent(Intent.ACTION_VIEW, myUrl);
startActivity(intent);

it opens the browser and than the mediaplayer.
ok...

but how to open the mediaplayer direct, without the need of the browser
and the result just the same (you know this autorotating and standart controls as it is)

cant be so hard.. looked in so many codes, but most try own streaming and embed the
video in there page etc.

i just like to call the mediaplayer, give him the url and done.

If this is not possible (what i nearly cant believe) for sure i would be interested how you do...

thanks
chris
guruk
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Mar 08, 2009 8:05 pm

Top

Postby nithin.warier » Mon Mar 09, 2009 5:54 am

Hi Guruk,

Actually i tried to play either from "data/misc" folder in android or from RAW folder, i didnt try the streaming part.. If that is enough for you, i am ready to give the source..

Thanks
Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Media player

Postby ibtmubarak » Tue Mar 10, 2009 11:12 am

hi nithin,

I m new in android sdk1.1. can u tell me,how to play video in android media player?....
mubarak
ibtmubarak
Developer
Developer
 
Posts: 44
Joined: Thu Feb 28, 2008 12:26 pm
Location: Bangalore

Postby nithin.warier » Tue Mar 10, 2009 2:04 pm

Hi ibtmubarak,

samples are there in API demos.. check that..

Thanks
Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Postby nithin.warier » Tue Apr 21, 2009 6:35 am

Hi Guruk,

Today, i just saw a link, so posting it, if you need, then fine..

http://blog.pocketjourney.com/2008/04/0 ... diaplayer/

Thanks
Nithin
smartandroidians.blogspot.com
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 26 guests