Exemple #1
0
    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        List <AudioEvent> events      = new List <AudioEvent>();
        String            projectPath = myVegas.Project.FilePath;
        AudioTrack        track;

        if (String.IsNullOrEmpty(projectPath))
        {
            MessageBox.Show("Please first create a project");
        }
        else if ((track = GetSelectedAudioTrack()) == null)
        {
            MessageBox.Show("You need to have at least 1 selected audio track");
        }
        else
        {
            AddSelectedAudioEvents(events);


            String dir      = Path.GetDirectoryName(projectPath);
            String fileName = Path.GetFileNameWithoutExtension(projectPath);
            defaultBasePath = fileName + "_tts.mp3";
            defaultBasePath = GetNextAvailableFilename(dir, defaultBasePath);
            String saveFileName = dir + "\\" + defaultBasePath;

            DialogResult result = ShowGoogleTTSDialog();
            if (DialogResult.OK == result)
            {
                if (TTSText.Text.Length == 0)
                {
                    MessageBox.Show("Enter some text will you?");
                }
                else
                {
                    GetSound(TTSText.Text, saveFileName);

                    // AudioEvent videoEvent = track.AddVideoEvent(start, length);
                    // Take take = videoEvent.AddTake(media.GetVideoStreamByIndex(0));
                    // myVegas.Transport.CursorPosition = cursorPosition;
                    myVegas.OpenFile(saveFileName);
                    AudioEvent evnt = GetSelectedAudioEvent();
                    evnt.ActiveTake.Name = TTSText.Text;


                    // MessageBox.Show();
                }
            }


            // MessageBox.Show(defaultBasePath);
        }
    }
        public bool RenderFile(FileInfo fiVeg, FileInfo fiRendered, RenderTemplate renderTemplate, RenderStatusManager rsm, object dr)
        {
            DateTime renderStart = DateTime.Now;
            DateTime renderEnd;
            TimeSpan renderTime;

            rsm.Dialog.Hide(); // Temporarily hide because during load the UX kills it.
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStart, renderStart);
            if (myVegas.Project != null)
            {
                // No close method so create a clean new project without the ability to prompt for save of existing
                // and then open after that.
                myVegas.NewProject(false, false);
            }
            myVegas.UpdateUI();
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStatus, "Loading");
            myVegas.OpenFile(fiVeg.FullName);
            myVegas.UpdateUI();
            myVegas.WaitForIdle();
            rsm.Dialog.Show();

            // Render
            RenderArgs ra = new RenderArgs();

            ra.OutputFile     = fiRendered.FullName;
            ra.RenderTemplate = renderTemplate;
            Timecode projectLength = GetProjectLength();

            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.ProjectLength, projectLength);
            ra.Length     = projectLength;
            ra.StartNanos = 0;

            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStatus, "Rendering");
            RenderStatus status = myVegas.Render(ra);

            renderEnd  = DateTime.Now;
            renderTime = renderEnd - renderStart;
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderEnd, renderEnd);
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderTime, renderTime);
            rsm.UpdateField(dr, RenderStatusManager.Fields.Names.RenderStatus, status.ToString());
            return(status == RenderStatus.Complete);
        }