简体   繁体   中英

MediaPlayer.create(Context, Uri) returns null, if Uri points to a file which has been renamed using FileExplorer

MediaPlayer.create(Context, Uri) returns null. I change the path of some file using FileExplorer app and then Uri points to that file. Uri is absolutely correct. But, I'm getting null instead of MediaPlayer object from this method. Any help?

I faced this problem in the past.After renaming that file, just check, whether that file can be opened from outside of your app.

I'm sure, that file cannot be opened.

So, just place a null check and show a Toast to the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM