I need to start and stop Blender’s animation playback (as if the user was hitting Alt-A) but I only know the
method. It acts like a toggle (just ike Alt-A!), so I need to find out whether Blender is already playing before I invoke it, otherwise playback stops. (and vice versa - if I want to stop Blender’s playback I need to know the user hasn’t already stopped it by hitting escape)
Is there an is_playing() sort of function I can use?
You could setup frame_change handlers. In the handler, check what frame you are on against the last frame. If they are different, then you are playing.
I don’t think that’ll work - by definition the frame_change handler is triggered whenever the frame is changed, whether or not Blender’s playing. Just clicking around in the timeline will trigger the handler.
If I check that the frame_current has only changed by one frame, it’ll still get confused if the user manually steps forward one frame (right cursor key).
Besides, I’m using frame_change handlers for other nefarious purposes and having to add “am-I-playing detection” is going to untidy things
Is there a way I can read Blender’s current playback fps, perhaps?
EDIT: Or is there a way to specifically start or stop playback, rather than just blindly toggling the playback state with animation_play()?
Ahhh - got it -
Thanks for the help
scr = bpy.context.screen #get current screen
is_Playing = scr.is_animation_playing #get play state(boolean)