@jetdv Sir,
I'm studying through your videos how to create scripts for Vegas. I'm literally learning from scratch. I'm trying to make this script that adds an image directly to the timeline. The script works when I use it on a video track, but when it contains an audio track the script does not work.
How do I make it work if the project has several audio tracks?
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using ScriptPortal.Vegas; namespace Test_Script { public class Class1 { public Vegas myVegas; public void Main(Vegas vegas) { myVegas = vegas; // Path to the image file you want to insert string imagePath = @"G:\00 - MARCADORES VEGAS\Decoração.jpg"; // Create a new media object Media media = new Media(imagePath); VideoTrack vidTrack = null; foreach (Track myTrack in myVegas.Project.Tracks) if (myTrack.IsValid()) { vidTrack = (VideoTrack)myTrack; } if (vidTrack == null) { VideoTrack newTrack = new VideoTrack(); myVegas.Project.Tracks.Add(newTrack); vidTrack = newTrack; } Timecode cursorLocation = myVegas.Transport.CursorPosition; Media mymedia = new Media(imagePath); if (mymedia.HasVideo()) { MediaStream stream = mymedia.Streams.GetItemByMediaType(MediaType.Video, 0); if (null != stream) { VideoEvent mynewVideoEvent = new VideoEvent(cursorLocation, stream.Length); vidTrack.Events.Add(mynewVideoEvent); Take mynewTake = new Take(stream); mynewVideoEvent.Takes.Add(mynewTake); } } } } public class EntryPoint { public void FromVegas(Vegas vegas) { Test_Script.Class1 test = new Test_Script.Class1(); test.Main(vegas); } } }