gpt4 book ai didi

android - 使用MediaPlayer进行Android流式传输:错误(1,-1004)和3GPP视频

转载 作者:行者123 更新时间:2023-12-03 05:43:25 24 4
gpt4 key购买 nike

我正在尝试制作一个用于播放视频的应用程序。我有2个问题:

1)我有一个Youtube的链接:rtsp://,我这样做:

“Uri myUri = Uri.parse(link); // link = rtsp:// ...
mMediaPlayer.setDataSource(getApplicationContext(),myUri);“

然后,该视频将无法播放...但是,如果我使用“videoview”,该视频就可以播放。我认为问题在于“mediaplayer”无法播放mpeg编解码器。有任何想法吗?

2)我有几个链接到不同的质量,我玩他们连接到无线网络,没有问题,但与数据连接:

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%D26%3%26%D26%3%26%D3%26%C3D26%3%26%D3D26%3%26%C3D%3D%26%C3D%3D%C3D%26%C3D%3D%26%C3D%26%C3D%26%D3%D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3。 %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播放已完成

希望您能提供帮助。
谢谢!

最佳答案

1)尝试不使用静态构造函数
2)使用标准构造函数创建一个mp对象,尝试使用setDataSource(),prepareAsync()等。
3)捕获null和非法状态异常。

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.getDuration()在mp.start()之后” + 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 ###");
}

关于android - 使用MediaPlayer进行Android流式传输:错误(1,-1004)和3GPP视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10399066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com