0
我嘗試Android的VideoView小部件時有一些奇怪的行爲。當我設置的URL編程(從網上報廢):我是否需要一個內容提供者將http視頻傳輸到android.widget.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)