我正在尝试播放视频的应用。我有两个问题:
1)我有一个Youtube的链接:rtsp://我做:
“Uri myUri = Uri.parse(link); // link = rtsp:// ... mMediaPlayer.setDataSource(getApplicationContext(),myUri);“
然后,视频无法播放...但是,如果我使用“视频视图”工作。我认为问题在于“媒体播放器”不会播放mpeg编解码器。有什么想法吗?
2)我有几个链接到不同的质量,我播放它们连接到wifi没有问题,但有数据连接:
05-01 15:58:25.453:E / Link:(31565):http%3A%2F%2Fo-o.preferred.mad01s04.v16.lscache3.c.youtube.com%2Fvideoplayback%3Fupn%3D35Zn4tL7Ibc% 26sparams%3Dcp%252Cid%252Cip%252Cipbits%252Citag%252Cratebypass%252Csource%252Cupn%252Cexpire%26fexp%3D900147%26itag%3D18%26ip%3D85.0.0.0%26signature%3DAACE528D596873408192BCDDF4ECFC7DDFD68EBB.575689C34D97BA9D750C7B40CC63B427E40E7838%26sver%3D3%26ratebypass%3Dyes% 26source%3Dyoutube%26expire%3D1335903378%26key%3Dyt1%26ipbits%3D8%26cp%3DU0hSSllLUV9MUkNOMl9RRVVEOnduVjJoRkFBMDBn%26id%3D8fb5ca7aa1a31f5e
05-01 15:58:25.464:I / AwesomePlayer(31648):setDataSource_l('http://oo.preferred.mad01s04.v16.lscache3.c.youtube.com/videoplayback?upn=35Zn4tL7Ibc&sparams= CP%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&安培; FEXP = 900147&安培; ITAG = 18&安培; IP = 85.0.0.0&安培;签名= AACE528D596873408192BCDDF4ECFC7DDFD68EBB.575689C34D97BA9D750C7B40CC63B427E40E7838&安培; sver = 3及ratebypass = YES&安培;源= YouTube和安培;到期= 1335903378&安培;键= YT1&安培; ipbits = 8&安培; CP = U0hSSllLUV9MUkNOMl9RRVVEOnduVjJoRkFBMDBn和ID = 8fb5ca7aa1a31f5e')
05-01 15:58:25.484:V / ChromiumHTTPDataSource(31648):代表uid 10101连接
05-01 15:58:25.484:I / ChromiumHTTPDataSource(31648):连接到http://o-o.preferred.mad01s04.v16.lscache3.c.youtube.com/videoplayback?upn=35Zn4tL7Ibc&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=900147&itag=18&ip=85.0.0.0&signature=AACE528D596873408192BCDDF4ECFC7DDFD68EBB.575689C34D97BA9D750C7B40CC63B427E40E7838&sver=3&ratebypass=yes&source=youtube&expire=1335903378&key=yt1&ipbits=8&cp=U0hSSllLUV9MUkNOMl9RRVVEOnduVjJoRkFBMDBn&id=8fb5ca7aa1a31f5e @ 0
05-01 15:58:26.226:I / ChromiumHTTPDataSourceSupport(31648):服务器以http状态403响应
05-01 15:58:26.226:I / AwesomePlayer(31648):mConnectingDataSource-> connect()返回-1004
05-01 15:58:26.226:E / MediaPlayer(31565):错误(1,-1004)
05-01 15:58:26.242:E / MediaPlayer(31565):错误(1,-1004)
05-01 15:58:26.242:E / RS(31565):MediaPlayer播放错误
05-01 15:58:26.242:V /(31565):介质错误,错误未知-1004
05-01 15:58:26.242:I / RS(31565):MediaPlayer Playback COMPLETED
我希望你能提供帮助。 谢谢!
答案 0 :(得分:0)
1)尝试没有静态构造函数 2)使用标准构造函数创建一个mp对象,尝试使用setDataSource(),prepareAsync()等。 3)捕获空和非法状态异常。
有一些错误& MediaPlayer api的限制。
请在我的示例代码中忽略isCanceleld()。
示例代码:
if (mp == null && isCancelled() != true) {
mp = new MediaPlayer();
mp.setDataSource(chnlUrlParam);
mp.prepareAsync();
mp.start();
// Log.d(“doInBackground”,mp.start()之后的“mp.getCurrentPosition()”+ mp.getCurrentPosition()); // Log.d(“doInBackground”,mp.start()之后的“mp.getDuration()”+ mp.getDuration()); mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener(){
@Override
public void onBufferingUpdate(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 ###");
}
答案 1 :(得分:0)
实际上由于存在此问题而存在错误的流式网址错误..否则它在视频视图中效果很好。
你必须在网址后添加youtube签名。
我努力了,它完美无缺。