maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Maemo 5/N900] Preventing audio playback being stopped by power button (https://talk.maemo.org/showthread.php?t=74187)

eagle_linux 2011-06-21 09:03

[Maemo 5/N900] Preventing audio playback being stopped by power button
 
Greetings,

I'm trying to write an alarm clock application in python using pyqt.
I've managed to get audio files to play, using mplayer at the moment. However, there's one quite annoying problem: Whenever the power button is pressed, the playback pauses for about a second, and then continues in most cases. Even more annoying, sometimes mplayer seems to choke on the forced pause and doesn't continue playing at all.

I was trying to use gstreamer instead, but the simple pygst program from the official pygst tutorial seems to exhibit the same behaviour, i.e. it pauses for a second when the power button is pressed.

As the official N900 media player also uses gstreamer afaik and doesn't pause when the power button is pressed, I guess there is a way to prevent this from happening.
Any help would be greatly appreciated. :)

Regards,
Eagle_Linux

eagle_linux 2011-06-28 12:55

Re: [Maemo 5/N900] Preventing audio playback being stopped by power button
 
121 Views and still no answer, damn :(

Doesn't anyone has an idea at least what could cause that behavior?
As far as I noticed, other "homebrew" programs like pannucci and someplayer show the same problem. Is there no way to get around that? Or am I the only one experiencing the pausing of any playback when the power button is pressed?

Here's the code I used to test gstreamer:

Code:

#!/usr/bin/env python

import gst
import gobject

player = gst.element_factory_make("playbin2", "player")
vis = gst.element_factory_make("goom","vis")
videosink = gst.element_factory_make("fakesink", 'videosink')

videosink.set_property('async', False)

audiosink = gst.element_factory_make("autoaudiosink", 'audiosink')
audiosink.set_property('async-handling', True)

player.set_property("vis-plugin", vis)
player.set_property("video-sink", videosink)
player.set_property("audio-sink", audiosink)
player.set_property("uri", 'file:///home/user/MyDocs/test.mp3') #exchange with your own file
player.set_state(gst.STATE_PLAYING)
gobject.MainLoop().run()

The file plays fine, but pauses/is silenced for a second if I press the power button, then continues. This is slowly driving me mad, as I often use the power button to unlock my N900, not the lock slider.

Regards,
Eagle_Linux

pelago 2011-06-28 13:51

Re: [Maemo 5/N900] Preventing audio playback being stopped by power button
 
I'm no expert, but I've read somewhere that the pause doesn't happen if you use MAFW to play the sound. This is the framework that the Nokia-supplied Media Player uses, which as you will have noticed, doesn't have that problem when you press the power button. There are also often stutters with non-MAFW apps (like Panucci, as you mention) when you use the right-hand side lock slider and when you rotate the device, by the way.

eagle_linux 2011-06-28 16:53

Re: [Maemo 5/N900] Preventing audio playback being stopped by power button
 
Thanks a bunch, I'll look into MAFW and its python bindings now. Seems like just the solution I was slooking for, as I was going to do it "the maemo way" anyway, and already assumed that I needed a different way to play audio for that. :)


All times are GMT. The time now is 01:19.

vBulletin® Version 3.8.8