Adding Tracks in C#

RichMcG wrote on 4/17/2003, 11:27 PM
Starting with a jscript example that added tracks to the current project, I tried to do the following:

Track Mytrack = new Track(MediaType.Audio);
proj.Tracks.Add(Mytrack);

I get a compiler error that tells me that
in C#.

Cannot create an instance of the abstract class or interface 'SonicFoundry.Vegas.Track'

Is this correct/possible?

Comments

roger_74 wrote on 4/18/2003, 4:28 AM
You should use VideoTrack or AudioTrack instead of the abstract class Track.
roger_74 wrote on 4/18/2003, 4:45 AM
Also, I recommend that you pass the whole vegas object to C# (if you haven't thought about that), instead of just the project. The vegas object has useful stuff like selectionstart/length and project load/save.
RichMcG wrote on 4/19/2003, 10:17 PM
Roger,


Thanks for your help, it moved me a little farther. Sorry for all these questions. I really think that once I get this part up and running, I'll have enough to chew on for quite some time. It compiles correctly but at runtime I get an error "Object reference not set to an instance of an object" for the following code:

SonicFoundry.Vegas.VideoTrack Mytrack = new SonicFoundry.Vegas.VideoTrack();
Myproj.Tracks.Add(Mytrack);

Didn't I just create an instance of that object?


Rich
roger_74 wrote on 4/20/2003, 4:23 AM
There's nothing wrong with your code. Are you sure you have an instance of Myproj passed from Vegas?
bcbarnes wrote on 4/21/2003, 6:45 PM
I figured out a while ago how to launch V4 from C#, but how do you get the vegas project object into C#?
JohnnyRoy wrote on 4/22/2003, 12:08 PM
> how do you get the vegas project object into C#?

You must pass it in from your JScript or VB code. That means you start with JScript or VB and call a method in your C# code that takes the Vegas object as a parameter. Then you can do whatever you want in C# with the Vegas object. You cannot start from C#. Vegas supports JScript and VB.Net. You can call any other .NET code you want from there but you must start with JScript or VB.

~jr