logo
down
shadow

play music with background service


play music with background service

By : A. Barkworth
Date : November 20 2020, 03:01 PM
it helps some times I'm not sure what your onPause() and onStop() are meant to do. However when you start a service for the first time using Context.startService() the onCreate() method of the service is called and then onStartCommand() is called and later when you call startService() again only the onStartCommand() is called. So for whatever reason if you want to play the sound in a service and pause that in the very same service, you need to provide the service an Action that specifies the action you want to do.
So in your activity when you want to tell the service to play the sound:
code :
String action = "PLAY";
Intent myService = new Intent(MainActivity.this, BackgroundSoundService.class);
myService.setAction(action);
startService(myService);
String action = "PAUSE";
Intent myService = new Intent(MainActivity.this, BackgroundSoundService.class);
myService.setAction(action);
startService(myService);  
if (intent.getAction().equals("PLAY")) {
    // resume the sound
}
if (intent.getAction().equals("PAUSE")) {
    // pause the sound
}


Share : facebook icon twitter icon
How to load/play music from the iPod library as background music in cocos2d? (iphone)

How to load/play music from the iPod library as background music in cocos2d? (iphone)


By : lfroidmo
Date : March 29 2020, 07:55 AM
Play selected music as background music for a game

Play selected music as background music for a game


By : Kevin
Date : March 29 2020, 07:55 AM
wish of those help The problem is that you're doing start before the player is prepared, check out this diagram
https://image.slidesharecdn.com/mediaplayer-110716092828-phpapp02/95/android-media-player-9-728.jpg?cb=1310809360
code :
private void play(Context context, Uri uri) {
    MediaPlayer mp = new MediaPlayer();
    mp.setDataSource(context, uri);
    mp.prepareAsync();
    mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            mediaPlayer.start();
    }
   });
}}
how background music pause and play when my app video is play in swift 3

how background music pause and play when my app video is play in swift 3


By : Dejair Sisconeto
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have created a small video application but when i play video the background music pause. but i want to play music again when video pause and when i play video again than music player will resume.
Why do we need a service in android? Music play can be done by background thread also

Why do we need a service in android? Music play can be done by background thread also


By : 郭启明
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Service: Service is like Activity. but it doesn't require UI to work with. whereas when the thread created from the activity , thread will run until the activity lives. so, if you play the music in thread it will run. but it will crash when the activity ends, whereas when you implemented the music playing from service it will run entire the life cycle of the service.
See my answer boundservice to communicate between service and activity. when your music player runs you have to maintain the notification on notification panel.
IOS How to play music sound in background and pause current playing music app

IOS How to play music sound in background and pause current playing music app


By : Doreen Pettus
Date : March 29 2020, 07:55 AM
With these it helps iOS will automatically pause other audio instances if your app begins one. Check out this thread: How to Play Audio in Background Swift?
Related Posts Related Posts :
  • Strange LiveData behavior vs ObservableField
  • Which layout is used for clash of clans home screen? We can scroll it horizontal as well as vertical. Please illuminate
  • RxJava: Know when observable is finished and return Boolean Observable to the caller
  • how to use savedInstanceState to save camera information when the orientation change occure
  • Style React-Native via Styles.xml
  • Keyboard won't show after calling InputMethodManager.showSoftInput
  • Compiling ffmpeg for Android on OSX
  • Button does not get clicked on the first attempt
  • AR Core performance, learning curve and comparison with other frameworks
  • Codename one : Attaching images to email message fails
  • Error: Unsupported type 'viewItem' in Android build
  • setLayoutParams on ConstraintLayout does not change size
  • How to profile the fetch time of the android gradle libraries
  • Kotlin setOnclickListener
  • Naming convention for methods returning RxJava's Completable
  • Conv3D not working
  • FFmpeg audio video merge command
  • Do you have to use gradle-experimental for JNI?
  • How to get key hashes for facebook for facebook app?
  • ZXing not calling onActivityResult, When scanning QR Code
  • Integration of Android Native module with existing Xamarin Native Project
  • Restore RecyclerView state after rotating
  • ViewModelProviders java.lang.RuntimeException trying to instantiate class which inherit AndroidViewModel
  • SKD19 vs SDK24 - Usage of API documented as @since 1.8+
  • filter option in list view fragment activity
  • Picture from camera not showing up in second activity
  • How to change imageview according to screen size
  • How to copy Android Studio project to remote Git (NOT GitHub) server
  • How to get React-Native to announce specific accessibility message via AccessibiliyManager?
  • Change colors of com.tech.freak.wizardpager.ui.StepPagerStrip
  • Android fullscreen activity shows ActionBar
  • Turn on the screen when timer calls onFinish()
  • Would like a bit of clarification with SQLite database's onUpgrade method
  • Use ObjectBox with Libgdx
  • How to make combine Gregorian and Hijri calendar in Android?
  • Try to read text file from sdcard in other language
  • "App not installed" message when installed apk
  • How to execute a designated test suite class in Firebase Test Lab
  • background not visible on LG G3
  • should every View have an id?
  • Realm object server sync on low connection.
  • Correct way to add more views to adapter
  • Getting error in android support library
  • Instant app zip uploading error
  • "No emulator installed" error in Android Studio even though Intel HAXM is up and running
  • AsyncTask without leaks
  • SQLiteException : No such table found whereas a table was created
  • Using @Component.Builder with constructor params
  • No injector was found for fragment dagger 2.11
  • Android Volley Https SSL self signed and Google Maps API
  • Why does the onClickListener not work anymore in this example?
  • Why are my map marker ObjectAnimators getting canceled?
  • Android App update only working after deleting all local data
  • Getting unknown attribute error in android studio
  • How to remove space in Toolbar
  • Phonegap - Push notification with embedded web app (InAppBrowser window)
  • Broadcast receiver is not triggered for incoming calls
  • How to know whether realm.commitTransaction() succefull
  • How to create title bar in android?
  • Control RecyclerView inflated views from outside the adapter: keep selection state
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org