Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Owner and Founder. Opencart
Playing audios directly without downloading it is an easy and fast way to use media and it also saves device memory. Playing media online also saves you from the headache of management of files in the device.
To stream audios, android provides a class MediaPlayer which is used to play online or offline media files in the app.
You can follow the below code segment and the explanation after that to stream the media directly from the URL.
As you can see in the above code segment that an object of MediaPlayer is created and the url is passed to the function setDataSource().
start() function is used to play the audio file on the URL.
Similarly to play the downloaded audio file. You can follow the below given code segment and the explanation following it.
This is similar to the playing media online except that you need to create() function and pass the file path to the as the parameter.
To perform some task after the completion of audio. you can use the MediaPlayer.OnCompletionListener() function. Check the code segment below
You can also use the isPlaying function to make a single button for play and pause.
Thank you very much, this is Vedesh Kumar signing off.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.