Inserting movies and images programmatically

daveydave wrote on 7/23/2003, 1:40 PM
I want to create a script that inserts media into a track.
How would I do this.
Below I have the start of my script.
It opens a directory and adds all the files to the media pool.
I also figured that I would have to create a video track.
But now how do I insert the media into the video track?

Some SIMPLE samples would be nice.

-----------------------
import System.Windows.Forms;
import SonicFoundry.Vegas;

try {
var fso, f, f1, fc, s;

// Vegas.Project(0,0);

// vegas.project.mediapool();

fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder("C:\\Documents and Settings\\dcornewell\\My Documents\\My Pictures\\pics\\");
fc = new Enumerator(f.files);

var track = new VideoTrack();
Vegas.Project.Tracks.Add(track);
for (; !fc.atEnd(); fc.moveNext())
{
//MessageBox.Show(fc.item());
var med = new Media(fc.item());
// Vegas.Project.MediaBin.Add(med);
}

} catch (e) {
MessageBox.Show(e);
}

Comments

jetdv wrote on 7/23/2003, 3:05 PM
You will need to do something like this:


//Add the media to the new track
var mymedia = new Media(MyTake.MediaPath); //change MyTake.MediaPath with the actual path to the media

if (MyTrack.IsVideo()) {
stream = mymedia.Streams.GetItemByMediaType(MediaType.Audio, 0);
if (null == stream)
throw "media contains no audio streams";
mynewEvent = new AudioEvent(MyEvent.Start, MyEvent.Length);
} else {
stream = mymedia.Streams.GetItemByMediaType(MediaType.Video, 0);
if (null == stream)
throw "media contains no video streams";
mynewEvent = new VideoEvent(MyEvent.Start, MyEvent.Length);
}

Mtrack.Events.Add(mynewEvent);
var myNewtake = new Take(stream);
mynewEvent.Takes.Add(myNewtake);