Android MediaPlayer错误(1,-22) [英] Android MediaPlayer Error (1,-22)

查看:121
本文介绍了Android MediaPlayer错误(1,-22)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在循环中长时间播放(大约一个小时或更长时间)同一曲目后,发生错误(1,-22).我不知道该错误的原因.如果音轨播放时间短,一切都会好起来的.但是,如果我在Service中长时间跟踪播放,有时会发生错误.

Error (1,-22) occurs after long playing (about hour or more) the same track in a loop. I can't figure out the reason of that error. Everything is okay if track is playing for short time. But if I keep track playing for long time in my Service, sometimes the error happens.

我知道1是MEDIA_ERROR_UNKNOWN,但找不到有关-22的任何信息.

I know that 1 is MEDIA_ERROR_UNKNOWN, but cant find anything about -22.

有什么建议吗? API 24

Any suggestions? API 24

推荐答案

似乎出现问题是因为在onCompletion回调时我没有调用MediaPlayer.release().结果,MP的资源没有释放,MP最终因错误而崩溃.

It seems to issue appears because I didn't call MediaPlayer.release() when onCompletion callback. As a result resources of MP did not released and finally MP crashed with the error.

这篇关于Android MediaPlayer错误(1,-22)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆