Hello, I have a problem with mediaplayer. I have a simple video that
should be played from internet. Sound works, but I can't get the
video...
Code:
public void onCreate(Bundle icicle) {
Log.v(TAG,"onCreate");
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mPreview = new VideoView(this);
setContentView(mPreview);
playVideo();
}
private void playVideo() {
try {
Log.v(TAG, "in play video");
final String path =
"http://213.143.65.190/getbkdfile.str?
ch=planet9.sou.sou&fn=a300a37718a8edf5342c465bacb3e811.mp4&showid=a300a37718a8edf5342c465bacb3e811&s=true";
Log.v(TAG, "path: " + path);
mp = MediaPlayer.create(this, Uri.parse(path));
Log.e(TAG, "path set!");
mp.setOnErrorListener(this);
mp.setDisplay(mPreview.getHolder());
setContentView(mPreview);
Log.e(TAG, "after setting display");
Log.v(TAG, "Duration: ===>" + mp.getDuration());
mp.start();
} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
if (mp != null) {
mp.stop();
mp.release();
}
}
}
public boolean onError(MediaPlayer mediaPlayer, int what, int extra)
{
Log.e(TAG, "onError---> what:" + what + " extra:" + extra);
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
}
return true;
}
Any help would be perfect...
I know I must not be far from the solution.. I think I just don't know
how to put mediaplayer to display...
Thanks in advance,
nejck
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en