本文整理汇总了C#中IMediaSeeking.SetTimeFormat方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaSeeking.SetTimeFormat方法的具体用法?C# IMediaSeeking.SetTimeFormat怎么用?C# IMediaSeeking.SetTimeFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaSeeking
的用法示例。
在下文中一共展示了IMediaSeeking.SetTimeFormat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayerCore
public PlayerCore(string file)
{
graphBuilder = (new FilterGraph()) as IFilterGraph2;
if (graphBuilder == null) return;
mediaControl = graphBuilder as IMediaControl;
mediaSeeking = graphBuilder as IMediaSeeking;
audioControl = graphBuilder as IBasicAudio;
if (mediaControl == null || mediaSeeking == null || audioControl == null) return;
//int hr = mediaControl.RenderFile(file);
FileInfo info = new FileInfo(file);
ISupport support = Supports.Instance[info.Extension];
int hr = -1;
if (support != null)
hr = support.RenderGraph(graphBuilder, file);
else
hr = mediaControl.RenderFile(file);
fileName = file;
if (hr != 0) errorStack.Push(hr);
if (hr != 0) return;
mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
isValidate = true;
window = graphBuilder as IVideoWindow;
if (window != null)
{
int width = 0;
int height = 0;
window.get_Width(out width);
window.get_Height(out height);
nativeSize = new Size(width, height);
}
}
示例2: SetMediaSeekingInterface
/// <summary>
/// Setup the IMediaSeeking interface
/// </summary>
protected void SetMediaSeekingInterface(IMediaSeeking mediaSeeking)
{
m_mediaSeeking = mediaSeeking;
if (mediaSeeking == null)
{
CurrentPositionFormat = MediaPositionFormat.None;
Duration = 0;
return;
}
/* Get our prefered DirectShow TimeFormat */
Guid preferedFormat = ConvertPositionFormat(PreferedPositionFormat);
/* Attempt to set the time format */
mediaSeeking.SetTimeFormat(preferedFormat);
Guid currentFormat;
/* Gets the current time format
* we may not have been successful
* setting our prefered format */
mediaSeeking.GetTimeFormat(out currentFormat);
/* Set our property up with the right format */
CurrentPositionFormat = ConvertPositionFormat(currentFormat);
SetDuration();
}
示例3: loadVideo
private void loadVideo(String videoPath)
{
videoFilepath = videoPath;
videoFileName.Text = getDisplayVideoName();
if (graph != null)
{
graph = null;
}
if (mediaControl != null)
{
// Stop media playback
this.mediaControl.Stop();
mediaControl = null;
}
if (videoWindow != null)
{
videoWindow.put_Owner(IntPtr.Zero);
videoWindow = null;
}
if (mediaSeeking != null)
{
mediaSeeking = null;
}
if (basicAudio != null)
{
basicAudio = null;
}
GC.Collect();
/* if (mediaPosition != null)
{
mediaPosition = null;
}*/
graph = (IGraphBuilder)new FilterGraph();
mediaControl = (IMediaControl)graph;
//mediaPosition = (IMediaPosition)graph;
videoWindow = (IVideoWindow)graph;
mediaSeeking = (IMediaSeeking)graph;
basicAudio = (IBasicAudio)graph;
AviSplitter spliter = new AviSplitter();
graph.AddFilter((IBaseFilter)spliter, null);
graph.RenderFile(videoPath, null);
graph.SetDefaultSyncSource();
/*
* AMSeekingSeekingCapabilities cap = AMSeekingSeekingCapabilities.CanGetCurrentPos;
if (mediaSeeking.CheckCapabilities(ref cap) > 0)
{
this.consoleErreur.AppendText("Impossible de recuperer la position de la frame");
}
* */
videoWindow.put_Owner(videoPanel.Handle);
videoWindow.put_MessageDrain(videoPanel.Handle);
videoWindow.put_WindowStyle(WindowStyle.Child);
videoWindow.put_WindowStyleEx(WindowStyleEx.ControlParent);
videoWindow.put_Left(0);
videoWindow.put_Top(0);
videoWindow.put_Width(videoPanel.Width);
videoWindow.put_Height(videoPanel.Height);
//positionTrackbar.Enabled = true;
speedTrackBar.Enabled = true;
mediaSeeking.SetTimeFormat(TimeFormat.Frame);
double rate;
mediaSeeking.GetRate(out rate);
rateText.Text = rate.ToString();
speedTrackBar.Value = (int)(speedTrackBar.Maximum * rate / 2);
trackBar1.Value = trackBar1.Maximum / 2;
this.basicAudio.put_Volume(-5000 + 5000 * trackBar1.Value / trackBar1.Maximum);
//mediaPosition.put_Rate(0.5);
running = false;
frameChanged = false;
}
示例4: CreateGraph
private void CreateGraph()
{
graphBuilder = (IGraphBuilder)new FilterGraph();
graphBuilder.RenderFile(tempFileName, null);
mediaControl = (IMediaControl)graphBuilder;
mediaSeeking = (IMediaSeeking)graphBuilder;
mediaEvent = (IMediaEventEx)graphBuilder;
//var filter = new MpqFileSourceFilter(File);
//DsError.ThrowExceptionForHR(graphBuilder.AddFilter(filter, filter.Name));
//DsError.ThrowExceptionForHR(graphBuilder.Render(filter.OutputPin));
mediaSeeking.GetCapabilities(out seekingCapabilities);
mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
mediaEvent.SetNotifyWindow(Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
}
示例5: openVid
//.........这里部分代码省略.........
vidScaleFactor.Text = "50%";
};
double p = double.Parse(vidScaleFactor.Text.Substring(0, vidScaleFactor.Text.IndexOf('%')));
p = p / 100;
int new_x = (int)(x * p);
int new_y = (int)(y * p);
videoWindow.put_Height(new_x);
videoWindow.put_Width(new_y);
videoWindow.put_Owner(videoPanel.Handle);
videoPanel.Size = new System.Drawing.Size(new_x, new_y);
videoWindow.SetWindowPosition(0, 0, videoPanel.Width, videoPanel.Height);
videoWindow.put_WindowStyle(WindowStyle.Child);
videoWindow.put_Visible(DirectShowLib.OABool.True);
}
else vidScaleFactor.Enabled = false;
// timer
actualizaFrames.Interval = 10;
actualizaFrames.Enabled = true;
//mediaControl.Run();
drawPositions();
framesFin.Enabled = true;
buttonAddFrameInicio.Enabled = buttonAddFrameInicio.Visible = true;
framesInicio.Enabled = true;
buttonAddFrameFin.Enabled = buttonAddFrameFin.Visible = true;
butClip.Enabled = false;
mediaSeeking.SetTimeFormat(DirectShowLib.TimeFormat.Frame);
videoInfo.FrameTotal = VideoUnitConversion.getTotal(mediaSeeking, videoInfo.FrameRate);
seekBar.Maximum = FrameTotal;
seekBar.TickFrequency = seekBar.Maximum / 10;
// VFW ( __ SOLO AVIs __ )
try
{
AVIFileWrapper.AVIFileInit();
int aviFile = 0;
IntPtr aviStream;
int res = AVIFileWrapper.AVIFileOpen(ref aviFile, fileName, 0x20, 0);
res = AVIFileWrapper.AVIFileGetStream(aviFile, out aviStream, 1935960438, 0);
videoInfo.KeyFrames = new ArrayList();
int nFrames = FrameTotal;
for (int i = 0; i < nFrames; i++)
{
if (isKeyFrame(aviStream.ToInt32(), i))
videoInfo.KeyFrames.Add(i);
}
setStatus(videoInfo.KeyFrames.Count + " detectados");
AVIFileWrapper.AVIStreamRelease(aviStream);
AVIFileWrapper.AVIFileRelease(aviFile);
AVIFileWrapper.AVIFileExit();
KeyframesAvailable = true;
/*
nextK.Enabled = true;
示例6: translateW_Load
private void translateW_Load(object sender, EventArgs e)
{
//this.MaximumSize = this.Size;
//this.MinimumSize = this.Size;
toolStripStatusLabel2.Text = "Cargando el Asistente de Traducción...";
// cargamos script
autoComplete = new ArrayList();
al = mW.al;
gridCont.RowCount = al.Count;
bool hasAutoComplete = (mW.script.GetHeader().GetHeaderValue("AutoComplete") != string.Empty);
for (int i = 0; i < al.Count; i++)
{
lineaASS lass = (lineaASS)al[i];
gridCont[0, i].Value = lass.personaje;
if (!autoComplete.Contains(lass.personaje) && !hasAutoComplete)
if (lass.personaje.Trim()!="")
autoComplete.Add(lass.personaje);
gridCont[1, i].Value = lass.texto;
}
if (hasAutoComplete) InsertAutoCompleteFromScript();
labelLineaActual.Text = "1 de " + (al.Count) + " (0%)";
textPersonaje.Text = gridCont[0, 0].Value.ToString();
textOrig.Text = gridCont[1, 0].Value.ToString();
// cargamos video
graphBuilder = (IGraphBuilder)new FilterGraph();
graphBuilder.RenderFile(videoInfo.FileName, null);
mediaControl = (IMediaControl)graphBuilder;
// mediaEventEx = (IMediaEventEx)this.graphBuilder;
mediaSeeking = (IMediaSeeking)graphBuilder;
mediaPosition = (IMediaPosition)graphBuilder;
basicVideo = graphBuilder as IBasicVideo;
basicAudio = graphBuilder as IBasicAudio;
videoWindow = graphBuilder as IVideoWindow;
try
{
int x, y; double atpf;
basicVideo.GetVideoSize(out x, out y);
basicVideo.get_AvgTimePerFrame(out atpf);
videoInfo.FrameRate = Math.Round(1 / atpf, 3);
int new_x = videoPanel.Width;
int new_y = (new_x * y) / x;
videoWindow.put_Height(new_x);
videoWindow.put_Width(new_y);
videoWindow.put_Owner(videoPanel.Handle);
videoPanel.Size = new System.Drawing.Size(new_x, new_y);
videoWindow.SetWindowPosition(0, 0, videoPanel.Width, videoPanel.Height);
videoWindow.put_WindowStyle(WindowStyle.Child);
videoWindow.put_Visible(DirectShowLib.OABool.True);
mediaSeeking.SetTimeFormat(DirectShowLib.TimeFormat.Frame);
mediaControl.Run();
}
catch { mW.errorMsg("Imposible cargar el vídeo. Debe haber algún problema con el mismo, y el asistente será muy inestable"); }
// activamos timers & handlers
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Enabled = true;
timer2.Tick += new EventHandler(timer2_Tick);
AutoSaveTimer.Tick += new EventHandler(timer3_Tick);
AutoSaveTimer.Enabled = true;
gridCont.CellClick += new DataGridViewCellEventHandler(gridCont_CellClick);
textPersonaje.TextChanged += new EventHandler(textPersonaje_TextChanged);
textTradu.TextChanged += new EventHandler(textTradu_TextChanged);
textTradu.KeyUp += new KeyEventHandler(textBox1_KeyUp);
textTradu.KeyDown += new KeyEventHandler(textTradu_KeyDown);
textTradu.KeyPress += new KeyPressEventHandler(textTradu_KeyPress);
textPersonaje.KeyDown += new KeyEventHandler(textPersonaje_KeyDown);
textPersonaje.KeyPress += new KeyPressEventHandler(textPersonaje_KeyPress);
button8.GotFocus += new EventHandler(button8_GotFocus);
button9.GotFocus += new EventHandler(button9_GotFocus);
gridCont.DoubleClick += new EventHandler(gridCont_DoubleClick);
gridCont.SelectionChanged += new EventHandler(gridCont_SelectionChanged);
gridCont.KeyUp += new KeyEventHandler(gridCont_KeyUp);
listBox1.KeyUp += new KeyEventHandler(listBox1_KeyUp);
textToAdd.KeyPress += new KeyPressEventHandler(textToAdd_KeyPress);
progressBar1.MouseDown += new MouseEventHandler(progressBar1_MouseDown);
tiempoInicio_.TimeValidated += new TimeTextBox.OnTimeTextBoxValidated(tiempo_TimeValidated);
tiempoFin_.TimeValidated += new TimeTextBox.OnTimeTextBoxValidated(tiempo_TimeValidated);
this.Move += new EventHandler(translateW_Move);
//textTradu.ContextMenu = new ASSTextBoxRegExDefaultContextMenu(textTradu);
mediaControl.Pause();
// cargar de config
try
{
checkAutoComplete.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_autoC"));
checkTagSSA.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_tagSSA"));
checkComment.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_Comment"));
checkVideo.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_aud"));
//.........这里部分代码省略.........