Find Jobs
Hire Freelancers

Move MediaPlayer to a Service. Troubleshoot issues surrounding loops when phone sleeping.

£10-20 GBP

Completed
Posted about 10 years ago

£10-20 GBP

Paid on delivery
I already have a fully functioning application that plays sounds when the user presses buttons on the MainActivity. There are around 15 sounds that loop continuously and 15 buttons. I need to move the MediaPlayer from MainActivity into a Service and to only have ONE general MediaPlayer Service for every single sound that needs to be played. Currently the buttons on click associate a resId that the MediaPlayer uses to play the correct sound. An example of this is: public void onClick(View v) { int resId; switch ([login to view URL]()) { case R.id.button_1: resId = [login to view URL]; break; case R.id.button_2: resId = R.raw.brown_noise; break; default: resId = [login to view URL]; break; } // Release any resources from previous MediaPlayer if (mp != null) { [login to view URL](); } // Create a new MediaPlayer to play this sound mp = [login to view URL](this, resId); [login to view URL](true); [login to view URL](); The MediaPlayer service needs to be able to listen for the resId and to play the correct sound accordingly. ONE MediaPlayer Service needs to be able to play ALL sounds and to play the correct sound depending on button press. As well as this, the developer needs to rewrite sections of code such as: PhoneStateListener phoneStateListener = new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) { if ([login to view URL]() && state == TelephonyManager.CALL_STATE_RINGING) { [login to view URL](0,0); } else if([login to view URL]() && state == TelephonyManager.CALL_STATE_IDLE) { [login to view URL](1,1); } else if([login to view URL]() && state == TelephonyManager.CALL_STATE_OFFHOOK) { [login to view URL](0,0); } [login to view URL](state, incomingNumber); } }; TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); if(mgr != null) { [login to view URL](phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); } To work with the MediaPlayer Service as MainActivity will no longer be able to determine isPlaying() and will not be able to set the MediaPlayer volume as the MediaPlayer is outside of it, and is instead inside the Service. This section will need writting also: [login to view URL](new [login to view URL]() { public void onClick(View v) { if(null!=mp){ [login to view URL](); [login to view URL](R.drawable.ic_action_volume_muted); } To ensure that the STOP button on the MainActivity will be able to tell the MediaPlayer Service to release() the MediaPlayer. Additionally the developer will need to troubleshoot issues surrounding the MediaPlayer loops having a 0.5 second gap between them when the phone goes to sleep (Is locked or the screen dims). The sounds should loop continuously and seamlessly until the STOP button is called.
Project ID: 5503667

About the project

6 proposals
Remote project
Active 10 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi. I have lots of experience in android development and I have worked with playing sounds in android on button click. let me try it
£23 GBP in 2 days
5.0 (154 reviews)
6.6
6.6
6 freelancers are bidding on average £42 GBP for this job
User Avatar
Hi sir i want to work on your project. Please message me your project's Download link so we can start working on it. Waiting for your response. :)
£30 GBP in 3 days
5.0 (26 reviews)
4.1
4.1
User Avatar
Hi Dear I'm an Android Expert. I can help you. Please let's discuss in more detail. Best Regards
£33 GBP in 1 day
5.0 (3 reviews)
2.9
2.9
User Avatar
Đề xuất vẫn chưa được gửi
£20 GBP in 3 days
5.0 (1 review)
0.0
0.0
User Avatar
Hey This one if fairly simple. I have done the same thing in the past. If you send me a document with all the requirements and accept my off then I'll get started right away. I'm looking forward to workig on this project. Kinds regards Christophe
£133 GBP in 3 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED KINGDOM
Towcester, United Kingdom
5.0
1
Payment method verified
Member since Mar 1, 2014

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.