sorry for my poor English and this is my first topic.
I’m looking for a way to add actions to animation_data.nla_tracks some times corresponding to specific frames, in details I’m trying to simulate operator work on PC, each time the operator click on a key on the keyboard I want to play a sound on the speaker I added near to PC.
The speaker has a sound as sound.mp3
I execute some times the following code varying value of frame:
speaker = bpy.data.objects['speaker_operator'] context.scene.frame_current = frame if speaker.animation_data is None: speaker.animation_data_create() anim_data = speaker.animation_data anim_data.use_nla = True if len(anim_data.nla_tracks.values()) == 0: track = anim_data.nla_tracks.new() else: track = anim_data.nla_tracks.values() action = bpy.data.actions.new(name='SOUND') strip = track.strips.new("click",frame,action)
Some thing goes wrong, in NLA editor I see SOUND actions corresponding to frames but the speaker does not play audio. My doubt is about the action object, how could I get a correct action?