RV Cookbook - How to get things done with RV in Python

Hey Patrick,

I’m trying to write a package that creates a menu enabling to load an audio file for the image sequence or quicktime being played, working the same as when you drag the audio file to the window as a layer.

So I’m doing this, which is supposed to work for what I need, from what I understand from the Mu documentation:

           commands.addToSource(audioFile)
           extra_commands.displayFeedback("loaded: " + audioFile, 10.0)

This generates no error, however nothing happens apart from the displayfeedback, and the audio file does not appear in the sources when I press X. But that is also the case if I drag the audio file to the window, except that it does play in that case.

I also tried addSource(audioFile) which actually loads the audio as a source in the source list, but does not add it to the currently playing source.

Any idea or suggestion?

Thanks.

Hi :waving_hand: ,

the way it should work is:

from rv import commands

# Find source you want to use (e.g. currently viewed)
source_node = commands.sourcesAtFrame(commands.frame())[0]

source_media: list[str] = commands.getStringProperty(f"{source_node}.media.movie")

# get audio file path
audio_file = "path/to/audio.wav"

# Add audio file to source media list
source_media.append(audio_file)

# Set source media list back to the source node
commands.setSourceMeda(source_node, source_media)

Cheers, Mirco

Thanks!
Will try that!

Thanks Mirco,

it does work!

I’ve noticed that this makes the source disappear from inputs though, which means it can’t be played in sequence with other media.

Any way to go around this minor issue?

Thanks again.

Cheers
sergeï