Qt Android : How to properly manage media playing in background - android

I'm developing a webradio app in qml with Qt 5.2. To play my radio stream I use a MediaPlayer qml element. This method allows to keep music playing when the user goes in other application, that's what I want. However when the user play an other media my radio stream doesn't stop and so there is two media playing in the same time.
I have checked with other media player app, this behavior is not normal in android. Normally the first media should automatically be paused when a second one starts playing.
Does anyone know how to reproduce this behavior with in Qt ?

Related

Can you pause all apps making an audio output in Android Studio?

I was wandering if it would be possible to pause all audio outputs in Android Studio.
As an example, let's say you were listening to Youtube Music or Spotify, what code wouldbe able to pause them. Not mute them. Pause them. Additionally, if it's possible could you make it that it goes back a few seconds (etc. 5s or 2s). Also, I would like it not to require to use any API's as I'd like it to be universal but if that's not possible, I would like it to be able to pause and revert a few seconds in Youtube Music (Premium) and the default Android Music Player.
Thank you.

How to disable audio capabilities for entire app

I have an app that plays videos using the video_player package. These videos have sound, but I don't want to play it. To achieve this, I use:
controller.setVolume(0.0)
The problem is whenever I open the app, even before playing a video, any background music stops.
I figure there must be a way to say "this app does not have sound capability" and then the OS won't pause any background music.
Is there a flutter specific way to do this, or should I look for iOS and Android specific solutions?
Thanks!

How to pause/stop video in Android from my application

In Android how can i pause video player from my application.
I am able to achieve this for music player but not for video.
(Note: my application is different from video player. Video is not running in my application. )
In Android how can i pause video player from my application
Contact the authors of the video player you want to control, and ask them if they have an API to allow third-party apps to control their video player.
In general, apps cannot control other apps this way.
I am able to achieve this for music player
It is possible that there is some music player that has a documented and supported API that you are using. Or, perhaps you are attacking some music player with security issues. Many Android developers are capable of creating a music player that cannot be controlled by third-party apps, so please do not assume that whatever you did will work across all music players.

How can I auto-pause the audio player in my app when another app starts to play audio?

My app plays an audio file. I want my app to pause the audio playing if another apps starts to play audio. I don't want the two audio sounds mess up each other. My app will resume the audio playing after the other app finishes playing its audio. How can I make it? Thanks.
Depending on how your application is running ie. while app is running in foreground (users is looking at your screen) or if your running a "service" which is currently in the background and you wish music to continue playing (songza, slacker radio etc.) how you handle these things will be different. Android uses internal system states to determine which apps should be out-putting audio to the speaker. All this is handled by the audio manager requestAudioFocus() releaseAudioFocus() will be the system calls you will want to look at the most. For a more detailed explanation see android developer api where you this is explained and documented quite well http://developer.android.com/guide/topics/media/mediaplayer.html

Android: when implementing a music player in my app, can i make sure there is no other media playing playing music right now?

I want my app to play music while it is running, but I don't want the music to overlap with the music currently being played from a different application (android music app or other external music app such as pandora, grooveshark or winamp).
My question is: is there a way to make sure that nothing else is playing right now regardless of the source?
Thanks!
As of android 2.2 you can use AudioManager.requestAudioFocus(), other audio players should listen for this focus change request and can stop/pause/lower volume of their audio according to what type of audio your focus requests. However not all audio playing apps have bothered to implement this yet.
To be nice you should also listen for audio focus change requests from other apps and pause your apps audio accordingly.
On earlier versions of android calling mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); will usually stop any other music from playing

Categories

Resources