I am trying to play the mp3 file from web using media player class , on some devices it is working fine but for few devices it is giving following error .
QCMediaPlayer mediaplayer NOT present Unable to create media player error (-38, 0) Attempt to call getDuration without a valid mediaplayer
any help on this will be of great help.
In general error -38 means you are trying to call a function in wrong state for the player.
In your case as error says, you call getDuration()
when player is not prepared or started. Set setOnPreparedListener()
then start the player mp.start()
, then you can call getDuration()
.
Check this Tutorial to stream audio from web
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.