hi, i modified a script that process media pool files, to replace original with proxy files for better editing.
it look for files with same name but different extensions to replace in the media pool. worked fine in v10. now in v13 and V14, it has following error.
Error HRESULT E_FAIL has been returned from a call to a COM component
Can anyone help check what is the problem? Thank you!!
import System.Text;
import System.IO;
import SonicFoundry.Vegas.Script;
import System.Windows.Forms;
import System.Collections;
import Sony.Vegas;
try
{
var mediaKeys : ArrayList = new ArrayList()
//var enumMedia : IEnumerator = Vegas.Project.MediaPool.GetEnumerator();
// Copy the keys of all the media into an array
var enumMedia : IEnumerator = Vegas.Project.MediaPool.GetEnumerator();
while (enumMedia.MoveNext())
{
var media : Media = enumMedia.Current;
var mediaFilePath = media.FilePath;
var UpperCaseString = mediaFilePath.toLocaleUpperCase(); //convert to upper case
if(!media.IsSubclip())
{
if(UpperCaseString.Length > 3)
{
var result1 = UpperCaseString.Substring(UpperCaseString.Length-4,4).Equals(".MP4");//Verify whether it contains .MP4
if (result1==1)//can replace
{
var TargetPath = UpperCaseString.replace(".MP4", "");
media.ReplaceWith(new Media(TargetPath));
mediaKeys.Add(media.KeyString);
}
var result1 = UpperCaseString.Substring(UpperCaseString.Length-4,4).Equals("SED)");//Verify whether it contains .MP4
if (result1==1)//can replace
{
var TargetPath = UpperCaseString.replace(".MP4", "");
media.ReplaceWith(new Media(TargetPath));
mediaKeys.Add(media.KeyString);
}
}
}
}
// Iterate through the array removing media files from the pool
for (var keyName in mediaKeys)
{
Vegas.Project.MediaPool.Remove(keyName);
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}