【发布时间】:2019-09-10 06:08:08
【问题描述】:
我正在尝试在 Android 的 VideoView 中播放视频,但它总是给出 (1 -2147483648) 错误。
起初,我尝试从 URL 播放,但没有成功,所以我下载了视频,将其保存在 raw 文件夹中并尝试播放,但仍然无法播放。 当我用谷歌搜索错误(1 -2147483648)时,它说这个错误是由于 URL 不正确或格式不兼容等问题而发生的,但视频是带有 H264 编解码器的 .mp4。 为了播放视频,我还应该考虑什么?
//活动
video_view.setMediaController(MediaController(context))
val videoPath="android.resource://" + context!!.packageName+ "/" + R.raw.howappvideo
video_view.setVideoURI(Uri.parse(videoPath))
video_view.requestFocus()
video_view.setOnPreparedListener {
Log.i("SeeAllFragment","video is prepared")
try{
video_view.start()
}catch (e:Exception){
Log.i("SeeAllFragment","error while playing ${e.printStackTrace()}")
}
}
video_view.setOnCompletionListener { mp ->
toast("video completed")
mp!!.release()
}
video_view.setOnErrorListener { mp, what, extra ->
Log.i("SeeAllFragment","error while loading video $what $extra ")
true
}
【问题讨论】: