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.
Related
I would like to develop an app with which you can control the focus of individual sound outputs, so that you can, for example, play music with Spotify and at the same time play a video via Youtube, which then no longer has any sound. Is something like that even possible?
Thanks for an answer
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!
I need to develop an Android Service (API level > 21), which should be able to detect video playback on a third party Video player, so that it can further disable the Notification pop-ups during a video playback.
On searching, I found several posts talking about detecting the play-states of videos in a VideoView, such as the following:
How to detect when VideoView starts playing (Android)?
But, I couldn't find anything that can help detecting video playback on a video player, wherein, the video player is installed as a third party app and is not a part of the Android application/ service.
So, the challenges are:
1) The android service needs to detect a video playback
2) Registering package names for video player apps with the Service is out of question, since the Service should be able to detect the playback even when a new video player is installed from the Playstore.
3) Need to extend this idea for online video streaming as well.
Any help in this regard would be really appreciated.
Thanks in advance.
There is no way to implement 100% reliable video playback detection :(
Just and idea: try listening to the audio focus changes... this might help with detection of video playback, assuming the target player respects the audio output stream usage policy, recommended by Google. You might also want to get notified about system UI visibility changes (to detect fullscreen playback).
Audio focus:
https://developer.android.com/guide/topics/media-apps/volume-and-earphones.html
System UI visibility changes:
https://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html
Also, you are correct saying that package name based detector is not an option since detecting active/running package is no longer possible on android 7.
I'm looking to make an Android app that can process music being played by another app. More specifically I want to analyze the raw audio. I've done some research and looked around, but I'm beginning to think this isn't possible, and maybe for good reason.
Does anyone have any ideas on how I might be able to achieve this capability?
as your requirement is to analyse all aps audio and want to process raw audio too.only one possibility is there which is to start recorder in background service and analyse audio all the time like many of the call recorder app on play store is doing to record a call.
it does have some drawbacks too
background noise
you will not able to know when music starts and when stops.
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