Python should reset PulseAudio
-
@digi6622 Is this you trying to stop playback by stopping the pulseaudio service?
That command works in the Terminal app because it is an unconfined system app. Confined apps are not allowed to go about randomly controlling other processes.
-
@arubislander
Thanks, Arubislander.
It's a little bit frustrating but I will continue to search for the right solution. -
@digi6622 Did you try maybe playing a short audio file in your app? Does it then stop the music app playback? If so, then refine that process: provide an empty source, or maybe just invoke stop() on the media player without playing anything at all?
I suspect what you are trying to achieve might even be possible without using Python at all.If of course your aim is to experiment with Python on Ubuntu Touch, then maybe try something that doesn't involve manipulating system processes from the command line
-
@digi6622 You might want to take a look at this Intro to Development on UTouch. There is also an email address, training-support(at)ubports(dot)com, where you can request assistance if there is anything you don't understand.
Of course there is also the App Dev Telegram channel for more unstructured questions and maybe more immediate assistance.
-
@arubislander
Thanks for your kind support and the encouraging words.I think I found a solution in
https://forums.ubports.com/topic/7981/change-volume-from-command-line/10?lang=de
At least it sounds like a possible solution if UT plays along.
The command "pactl" should do the trick.
-
@digi6622 said in Python should reset PulseAudio:
The command "pactl" should do the trick.
I hate to rain on your parade, but executing an external command from a confined app is simply not supported.
But, why would you want to 'stop' playback by changing the volume of the speakers? Maybe take a look here for doing what you might want.
In short, your app will not be able to execute any command line tools unless you bundle those tools in the click with your app.
-
@arubislander
Thanks again.
Now, I give up the project. Maybe someday I will start a new and completly different. -
@digi6622 I can only encourage you not to give up if the project is important to you. Maybe slide I to my DM's to talk it through? I am sure it is possible to achieve your goal in a way that does not fight the system.
-
Maybe slide I to my DM's to talk it through?
That would be really nice !
In short words what my app should do:-
Select a certain number of minutes (it already works)
-
Go to sleep for the number of minutes (works too)
-
After this time the app close media-hub or decrease volume of this soundchannel or mute pulseaudio (= my problem)
-
-
@digi6622 and is using Python a hard requirement?
-
@arubislander said in Python should reset PulseAudio:
@digi6622 and is using Python a hard requirement?
It would be nice if possible. I'm not fit in C++ or other codings.
-
@digi6622 I ask because for what you want to do, you probably o ly need QML and some Javascript.
-
@arubislander
QML and Javascript are okay. -
@digi6622 I have prepared a code snippet that does what you want. The Main.qml references silence.wav, which is a one second of silence wav file in the assets folder, created with Audacity. When the button is clicked the wav file is played, interrupting and superceding anything else that might have been playing.
Don't forget to add the "multimedia" profile to your apparmor file (appname.apparmor).
This can be run in a confined app, and does not require trying to manipulate commands and services external to the application.
I would like to reiterate that, as a proof of concept and by way of exercise, this is all very well. But a proper sleep functionality should be either implemented in the OS somewhere, as a global feature (maybe in settings?), or in the Music app itself as a local feature.
-
@arubislander
Thanks again !!!
It sounds very simple. Actually, I had assumed that the sound outputs (media-hub and playing a wav-file) were on different sound slots and thus did not affect each other. Therefore I did not think in this direction at all. But I give it a try. Thanks a lot.I would like to reiterate that, as a proof of concept and by way of exercise, this is all very well. But a proper sleep functionality should be either implemented in the OS somewhere, as a global feature (maybe in settings?), or in the Music app itself as a local feature.
I understand your concerns. Neverteheless I would like to offer my app in the OpenStore, because some members here in the forum (including me) wish this app. The maintainers of UT and MediaPlayer did not respond to this request.
-
@digi6622 I don't see any feature requests about what you describe here: https://gitlab.com/ubports/development/core/mediaplayer-app/-/issues
Where was the request made if nobody responded to it? -
@klh said in Python should reset PulseAudio:
@digi6622 I don't see any feature requests about what you describe here: https://gitlab.com/ubports/development/core/mediaplayer-app/-/issues
Where was the request made if nobody responded to it?You can find requests here:
https://open-store.io/app/com.ubuntu.music
https://forums.ubports.com/topic/4879/flas-sleep-timer -
Just a few basic thoughts from me:
Many mobile OS have disappeared because there simply wasn't much choice in apps. UT also doesn't have a wide distribution because there aren't many apps available. My wife would never switch from Android to UT for this reason. She simply lacks the little "helpers".
Therefore, it is important that every app, no matter how small, should be gratefully accepted. Every developer should be encouraged to continue to work for the community in his spare time (thanks to arubislander). His intentions should not be questioned. It doesn't have to be the huge "you-can-do-anything" app. Even the smallest app strengthens the OS. That's the only way UT can become something big. -
@digi6622 said in Python should reset PulseAudio:
You can find requests here:
https://open-store.io/app/com.ubuntu.musicThe app ratings section is not the best place to make requests.
There is already a feature request here, and a merge request here. Please upvote the issue to signal interest. The MR is still a WIP by the way, maybe offer to help bring it to a state where it could be merged into the app?
-
@digi6622
You're absolutely right, contribution to the apps ecosystem is very important and every contribution is appreciated.
I wanted also to thank you for taking the time and effort to come here to ask about how to develop this feature and be patient about how it works.I know some people are just searching for a hacky-hack way to get it done and if frustrated then will simply drop the idea.
And that's also important for us to be able to take the time to put you in the right direction like @arubislander did (thanks for that).Ubuntu-Touch is not the typical Linux distro, it is a mobile OS with its constraints so the users can have the best OS possible.