![](/img/trans.png)
[英]java.lang.ClassCastException: com.twilio.video.VideoTextureView cannot be cast to android.widget.VideoView
[英]Do I need a content provider to stream http video to android.widget.VideoView?
試用Android的VideoView小部件時,我有一些奇怪的行為。 當我以編程方式設置網址(從互聯網上刪除)時:
val url = getURLOnline()
val video = Uri.parse(url)
videoView.setVideoURI(video)
我收到以下錯誤:
MediaPlayer: Couldn't open "http://cdn.samplemediafile.xyz/thevideo.mp4": java.io.FileNotFoundException: No content provider: "http://cdn.samplemediafile.xyz/thevideo.mp4"
NuPlayer: onSetVideoSurface(0xa93b3000, no video decoder)
FileSource: Failed to open file '"http://cdn.samplemediafile.xyz/thevideo.mp4"'. (No such file or directory)
有趣的是,當我對相同的URL進行硬編碼時,它突然可以正常工作! 因此,這不是編解碼器問題。 當然,我也嘗試了其他視頻。 結果相同,只有硬編碼的作品。 這是為什么?
val video = Uri.parse("http://cdn.samplemediafile.xyz/thevideo.mp4")
videoView.setVideoURI(video)
找到了! 愚蠢的編碼錯誤...
Failed to open file '"http://cdn.samplemediafile.xyz/thevideo.mp4"'
^ ^
URL返回,並用引號引起來。 需要修復我的抓取代碼。 視頻現在播放良好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.