Also, even though I tell Emacs to draw the image first (using
`insert-image-file'), it is not displayed until the sound has stopped
playing (I use `play-sound-file'). Any way around this?
Thanks!
/Mathias
I don't know if this will work, but you could try let-binding
unread-command-events to nil while the sound is being played.
The idea is that any input events would be added to the queue,
but when the sound is done the queued events would be discarded
and the command loop wouldn't see them.
--
Kevin Rodgers
Denver, Colorado, USA
Thanks! It sounded like a good idea but it did not work. This is what
I did:
(defun esb-play (thing)
"Play sound and display image for THING."
(let ((unread-command-events nil))
(esb-display-image (concat esb-data-dir thing ".jpg"))
(play-sound-file ...
...
If I keep a key pressed or type it repeatedly it will still
"record" (queue?)
what is pressed during play.
Any other ideas?
/Mathias
Put a keymap in emulation-mode-map-alist with `ignore' as default key
during the play?
If you sound is played syncroneously, just introduce a global
variable, set it on during sound play, and do sound play conditionally
- only if the variable is not set.
If the play is async - may be much harder...
Hope this helps,
Ilya
The problem is not that the same sound is played at the same time, the
problem is that during the play the system accepts more keyboard
events and adds them to the queue, later playing sound when the key
binding is executed. If I use a global variable it will work in the
sense that no other/new sound will be played during play, but when the
playing is done and I set the global variable to false again the next
keyboard event will fire. Right?
You don't happen to have a recipe for that, do you? :) I tested it
briefly but either I did not do it correctly or the approach does not
work.
Can't I just temporarily rebind the key that played the current
"thing" and rebind it again afterwards in my own keymap?
I solved the first problem by saving the time when the sound is
playing and then refusing to play a sound again until at least a
second has passed. Feels ugly but seems to work okay.
Any takers on the second problem? Can I force redisplay of the image
in the display buffer before the sound is played?
Hehe, turns out there is a function called `redisplay' and when I put
that between the display of the image and the playing of the sound I
get what I want. Yay!
Look in tabkey2.el
> Can't I just temporarily rebind the key that played the current
> "thing" and rebind it again afterwards in my own keymap?
Yes, of course. The way above is perhaps more general if you want to redo it.
There is also a function `discard-input', which might be helpful.
-ap
Aha! First I did not think it helped, I had the call to it before I
play the sound. When I moved it to afterwards it works as I want it
to. I guess it makes sense: *after* playing I want to get rid of any
input events I got in the meantime. Now I can get rid of the ugly
measure-time-hack.
Many thanks, Andreas!