android - mediaPlayer setDataSource 不起作用

标签 android

我尝试在我的 Android 应用程序上添加视频,如页面:MediaPlayer

但是有错误:

enter image description here

例如,为什么此行不起作用:

mediaPlayer.setDataSource(url);

还有这一行:

mediaPlayer.prepare(); // might take long! (for buffering, etc)

我不明白,因为它是developer.android.com 示例。 你能帮我理解一下吗?

谢谢(如果我的问题很愚蠢,我很抱歉)。

最佳答案

setDataSource(String)抛出您未捕获的 IOExceptionIllegalArgumentException。您应该将这两个调用包装在 try-catch block

关于android - mediaPlayer setDataSource 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33385832/

相关文章:

android - setPreviewDisplay 和 setDisplayOrientation

android - Httpclient 重定向处理程序

android - 如何显示大于手机屏幕尺寸的图像?

android - 如何在 TableLayout 中垂直拉伸(stretch)一行?

java - 将路径点添加到 Google map Intent (Android)

java - 应用程序类是在 UI 线程上运行还是?

JAVA - 从迭代列表中删除非迭代器元素

android - 在 android 中发送带有联系表的邮件?

android - 比屏幕大的ImageView作为背景

android - TextView 未在自定义 View 中更新