Android Streaming With Mediaplayer: Error(1, -1004) And 3gpp Video
I'm trying to do an app for play video. I've 2 problems: 1) I've a Youtube's link: rtsp:// and i do: 'Uri myUri = Uri.parse(link); //link = rtsp://... mMediaPlayer.setDataSource(ge
Solution 1:
1)try without static constructor 2)create a mp object with standard constructor, Try using setDataSource(), prepareAsync() etc. 3)Catch null and illegal state exceptions.
There are some bugs & limitations with MediaPlayer api.
Please ignore isCanceleld() in my sample code.
sample code:
if (mp == null && isCancelled() != true) {
mp = new MediaPlayer();
mp.setDataSource(chnlUrlParam);
mp.prepareAsync();
mp.start();
// Log.d("doInBackground", "mp.getCurrentPosition() after mp.start() "+ mp.getCurrentPosition()); // Log.d("doInBackground","mp.getDuration() after mp.start() " + mp.getDuration()); mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
@OverridepublicvoidonBufferingUpdate(MediaPlayer mp,
int percent) {
Log.d("TAG_Async", "percent: " + percent);
}
});
}
if (mp == null) {
Log.d(TAG_Async,"### Failed to create media player from static constructor ###");
}
Solution 2:
Actually there is an error is streaming url error due to which this problem exists.. otherwise it works well in videoview.
you have to add youtube signature after the url.
I worked on that and it works perfectly.
Post a Comment for "Android Streaming With Mediaplayer: Error(1, -1004) And 3gpp Video"