本文整理汇总了C#中IMediaControl.Run方法的典型用法代码示例。如果您正苦于以下问题:C# IMediaControl.Run方法的具体用法?C# IMediaControl.Run怎么用?C# IMediaControl.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediaControl
的用法示例。
在下文中一共展示了IMediaControl.Run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowMedia
/// <summary>
/// Plays the given mediafile in the internal mediaplayer
/// </summary>
/// <param name="FilePath">File to play</param>
public void ShowMedia(string FilePath)
{
StopMedia();
Lbl_CurrentMedia.Text = Path.GetFileName(FilePath);
m_objFilterGraph = new FilgraphManager();
m_objFilterGraph.RenderFile(FilePath);
m_objBasicAudio = m_objFilterGraph as IBasicAudio;
try
{
m_objVideoWindow = m_objFilterGraph as IVideoWindow;
m_objVideoWindow.Owner = (int)panel2.Handle;
//m_objVideoWindow.Owner = (int)panel1.Handle;
m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
m_objVideoWindow.SetWindowPosition(panel2.ClientRectangle.Left,
panel2.ClientRectangle.Top,
panel2.ClientRectangle.Width,
panel2.ClientRectangle.Height);
}
catch (Exception ex)
{
Console.WriteLine(ex);
m_objVideoWindow = null;
}
m_objMediaEvent = m_objFilterGraph as IMediaEvent;
m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
m_objMediaEventEx.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0);
m_objMediaPosition = m_objFilterGraph as IMediaPosition;
m_objMediaControl = m_objFilterGraph as IMediaControl;
m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;
UpdateMediaButtons();
//UpdateStatusBar();
//UpdateToolBar();
}
示例2: cmdOpen_Click
private void cmdOpen_Click(object sender, EventArgs e)
{
// Allow the user to choose a file.
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
if (DialogResult.OK == openFileDialog.ShowDialog())
{
// Stop the playback for the current movie, if it exists.
if (mc != null) mc.Stop();
mc = null;
videoWindow = null;
// Load the movie file.
FilgraphManager graphManager = new FilgraphManager();
graphManager.RenderFile(openFileDialog.FileName);
// Attach the view to a picture box on the form.
try
{
videoWindow = (IVideoWindow)graphManager;
videoWindow.Owner = (int)pictureBox1.Handle;
videoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
videoWindow.SetWindowPosition(pictureBox1.ClientRectangle.Left,
pictureBox1.ClientRectangle.Top,
pictureBox1.ClientRectangle.Width,
pictureBox1.ClientRectangle.Height);
}
catch
{
// An error can occur if the file does not have a vide
// source (for example, an MP3 file.)
// You can ignore this error and still allow playback to
// continue (without any visualization).
}
// Start the playback (asynchronously).
mc = (IMediaControl)graphManager;
mc.Run();
}
}
示例3: StartRendering
/// <summary>
/// Begins rendering and returns immediately.
/// </summary>
/// <remarks>
/// Final status is sent as a <see cref="DESCombine.Completed"/> event.
/// </remarks>
public void StartRendering()
{
int hr;
if (m_State < ClassState.RenderSelected)
{
throw new Exception("Render method not selected");
}
m_State = ClassState.GraphStarted;
m_pControl = (IMediaControl)m_pGraph;
// Avoid double threads
if (threadCompleted)
{
// Create a new thread to process events
Thread t;
t = new Thread(new ThreadStart(EventWait));
t.Name = "Media Event Thread";
t.Start();
threadCompleted = false;
}
hr = m_pControl.Run();
DESError.ThrowExceptionForHR(hr);
}
示例4: Transcode
//.........这里部分代码省略.........
{
Log.Warn("DVR2MPG: FAILED:unable to get pins of muxer&source");
Cleanup();
return false;
}
bool usingAc3 = false;
AMMediaType amAudio = new AMMediaType();
amAudio.majorType = MediaType.Audio;
amAudio.subType = MediaSubType.Mpeg2Audio;
hr = pinOut0.Connect(pinIn1, amAudio);
if (hr != 0)
{
amAudio.subType = MediaSubType.DolbyAC3;
hr = pinOut0.Connect(pinIn1, amAudio);
usingAc3 = true;
}
if (hr != 0)
{
Log.Warn("DVR2MPG: FAILED: unable to connect audio pins: 0x{0:X}", hr);
Cleanup();
return false;
}
if (usingAc3)
Log.Info("DVR2MPG: using AC3 audio");
else
Log.Info("DVR2MPG: using MPEG audio");
AMMediaType amVideo = new AMMediaType();
amVideo.majorType = MediaType.Video;
amVideo.subType = MediaSubType.Mpeg2Video;
hr = pinOut1.Connect(pinIn0, amVideo);
if (hr != 0)
{
Log.Warn("DVR2MPG: FAILED: unable to connect video pins: 0x{0:X}", hr);
Cleanup();
return false;
}
//connect output of powerdvd muxer->input of filewriter
Log.Info("DVR2MPG: connect multiplexer->filewriter");
IPin pinOut, pinIn;
pinOut = DsFindPin.ByDirection(powerDvdMuxer, PinDirection.Output, 0);
if (pinOut == null)
{
Log.Warn("DVR2MPG: FAILED:cannot get output pin of Cyberlink MPEG muxer :0x{0:X}", hr);
Cleanup();
return false;
}
pinIn = DsFindPin.ByDirection(fileWriterbase, PinDirection.Input, 0);
if (pinIn == null)
{
Log.Warn("DVR2MPG: FAILED:cannot get input pin of Filewriter :0x{0:X}", hr);
Cleanup();
return false;
}
AMMediaType mt = new AMMediaType();
hr = pinOut.Connect(pinIn, mt);
if (hr != 0)
{
Log.Warn("DVR2MPG: FAILED:connect muxer->filewriter :0x{0:X}", hr);
Cleanup();
return false;
}
//set output filename
string outputFileName = System.IO.Path.ChangeExtension(info.file, ".mpg");
Log.Info("DVR2MPG: set output file to :{0}", outputFileName);
mt.majorType = MediaType.Stream;
mt.subType = MediaSubTypeEx.MPEG2;
hr = fileWriterFilter.SetFileName(outputFileName, mt);
if (hr != 0)
{
Log.Warn("DVR2MPG: FAILED:unable to set filename for filewriter :0x{0:X}", hr);
Cleanup();
return false;
}
mediaControl = graphBuilder as IMediaControl;
mediaSeeking = graphBuilder as IMediaSeeking;
mediaEvt = graphBuilder as IMediaEventEx;
Log.Info("DVR2MPG: start transcoding");
hr = mediaControl.Run();
if (hr != 0)
{
Log.Warn("DVR2MPG: FAILED:unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
}
catch (Exception ex)
{
Log.Error("DVR2MPG: Unable create graph: {0}", ex.Message);
Cleanup();
return false;
}
return true;
}
示例5: StartGraph
private void StartGraph()
{
int hr = 0;
CloseGraph();
string path = GetMoviePath();
if (path == string.Empty)
return;
try
{
graph = (IGraphBuilder) new FilterGraph();
filter = (IBaseFilter) new VideoMixingRenderer9();
IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9) filter;
hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
DsError.ThrowExceptionForHR(hr);
hr = filterConfig.SetNumberOfStreams(2);
DsError.ThrowExceptionForHR(hr);
SetAllocatorPresenter();
hr = graph.AddFilter(filter, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
hr = graph.RenderFile(path, null);
DsError.ThrowExceptionForHR(hr);
mediaControl = (IMediaControl) graph;
hr = mediaControl.Run();
DsError.ThrowExceptionForHR(hr);
}
catch
{
}
}
示例6: openMedia
private void openMedia()
{
openFileDialog1.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
if (DialogResult.OK == openFileDialog1.ShowDialog()) {
CleanUp();
m_objFilterGraph = new FilgraphManager();
m_objFilterGraph.RenderFile(openFileDialog1.FileName);
m_objBasicAudio = m_objFilterGraph as IBasicAudio;
try
{
m_objVideoWindow = m_objFilterGraph as IVideoWindow;
m_objVideoWindow.Owner = (int)panel1.Handle;
m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
catch(Exception) {
m_objVideoWindow = null;
}
m_objMediaEvent = m_objFilterGraph as IMediaEvent;
m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
m_objMediaEventEx.SetNotifyWindow((int) this.Handle, WM_GRAPHNOTIFY, 0);
m_objMediaPosition = m_objFilterGraph as IMediaPosition;
m_objMediaControl = m_objFilterGraph as IMediaControl;
this.Text = "Whistle- " + openFileDialog1.FileName + "]";
m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;
}
}
示例7: Init
public override void Init()
{
if (!isPlaying)
{
string Filename = "";
float size = 0;
double Max = 0;
int volume = 0;
graph = new FilterGraph() as IFilterGraph;
media = graph as IMediaControl;
eventEx = media as IMediaEventEx;
igb = media as IGraphBuilder;
imp = igb as IMediaPosition;
master.form.Invoke((MethodInvoker)delegate()
{
Filename = master.form.M_Filename.Text;
media.RenderFile(Filename);
size = (float)master.form.M_PrevSize.Value;
master.form.M_PrevSize.Enabled = false;
imp.get_Duration(out Max);
master.form.M_Seek.Maximum = (int)(Max);
master.form.M_Seek.Value = 0;
volume = master.form.M_Volume.Value;
span = (uint)(1000000.0f / master.form.M_CollectFPS);
});
graph.FindFilterByName("Video Renderer", out render);
if (render != null)
{
window = render as IVideoWindow;
window.put_WindowStyle(
WindowStyle.Caption | WindowStyle.Child
);
window.put_WindowStyleEx(
WindowStyleEx.ToolWindow
);
window.put_Caption("ElectronicBoard - VideoPrev -");
int Width, Height, Left, Top;
window.get_Width(out Width);
window.get_Height(out Height);
window.get_Left(out Left);
window.get_Top(out Top);
renderSize.Width = (int)(Width * size);
renderSize.Height = (int)(Height * size);
Aspect = (float)renderSize.Height / (float)renderSize.Width;
window.SetWindowPosition(Left, Top, renderSize.Width, renderSize.Height);
eventEx = media as IMediaEventEx;
eventEx.SetNotifyWindow(master.form.Handle, WM_DirectShow, IntPtr.Zero);
media.Run();
foreach (Process p in Process.GetProcesses())
{
if (p.MainWindowTitle == "ElectronicBoard - VideoPrev -")
{
renderwindow = p.MainWindowHandle;
break;
}
}
isPlaying = true;
iba = media as IBasicAudio;
iba.put_Volume(volume);
//master.form.checkBox3_CheckedChanged(null, null);
master.Start();
}
}
}
示例8: Transcode
//.........这里部分代码省略.........
return false;
}
}
Log.Info("TSReader2WMV: connect tsreader->audio/video decoders");
//connect output #0 (audio) of tsreader->audio decoder input pin 0
//connect output #1 (video) of tsreader->video decoder input pin 0
pinIn0 = DsFindPin.ByDirection(AudioCodec, PinDirection.Input, 0); //audio
pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video
if (pinIn0 == null || pinIn1 == null)
{
Log.Error("TSReader2WMV: FAILED: unable to get pins of video/audio codecs");
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut0, pinIn0);
if (hr != 0)
{
Log.Error("TSReader2WMV: FAILED: unable to connect audio pins :0x{0:X}", hr);
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut1, pinIn1);
if (hr != 0)
{
Log.Error("TSReader2WMV: FAILED: unable to connect video pins :0x{0:X}", hr);
Cleanup();
return false;
}
string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv");
if (!AddWmAsfWriter(outputFilename, quality, standard)) return false;
Log.Info("TSReader2WMV: start pre-run");
mediaControl = graphBuilder as IMediaControl;
mediaSeeking = tsreaderSource as IMediaSeeking;
mediaEvt = graphBuilder as IMediaEventEx;
mediaPos = graphBuilder as IMediaPosition;
//get file duration
long lTime = 5 * 60 * 60;
lTime *= 10000000;
long pStop = 0;
hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
if (hr == 0)
{
long lStreamPos;
mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position
m_dDuration = lStreamPos;
lTime = 0;
mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
}
double duration = m_dDuration / 10000000d;
Log.Info("TSReader2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration));
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("TSReader2WMV: FAILED: unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
int maxCount = 20;
while (true)
{
long lCurrent;
mediaSeeking.GetCurrentPosition(out lCurrent);
double dpos = (double)lCurrent;
dpos /= 10000000d;
System.Threading.Thread.Sleep(100);
if (dpos >= 2.0d) break;
maxCount--;
if (maxCount <= 0) break;
}
Log.Info("TSReader2WMV: pre-run done");
Log.Info("TSReader2WMV: Get duration of movie");
mediaControl.Stop();
FilterState state;
mediaControl.GetState(500, out state);
GC.Collect();
GC.Collect();
GC.Collect();
GC.WaitForPendingFinalizers();
Log.Info("TSReader2WMV: reconnect mpeg2 video codec->ASF WM Writer");
graphBuilder.RemoveFilter(fileWriterbase);
if (!AddWmAsfWriter(outputFilename, quality, standard)) return false;
Log.Info("TSReader2WMV: Start transcoding");
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("TSReader2WMV:FAILED:unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
}
catch (Exception e)
{
// TODO: Handle exceptions.
Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message);
return false;
}
return true;
}
示例9: Transcode
//.........这里部分代码省略.........
if (pinOut0 == null || pinOut1 == null)
{
Log.Error("DVRMS2WMV:FAILED:unable to get pins of source");
Cleanup();
return false;
}
pinIn0 = DsFindPin.ByDirection(Mpeg2VideoCodec, PinDirection.Input, 0); //video
pinIn1 = DsFindPin.ByDirection(Mpeg2AudioCodec, PinDirection.Input, 0); //audio
if (pinIn0 == null || pinIn1 == null)
{
Log.Error("DVRMS2WMV:FAILED:unable to get pins of mpeg2 video/audio codec");
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut0, pinIn1);
if (hr != 0)
{
Log.Error("DVRMS2WMV:FAILED:unable to connect audio pins :0x{0:X}", hr);
Cleanup();
return false;
}
hr = graphBuilder.Connect(pinOut1, pinIn0);
if (hr != 0)
{
Log.Error("DVRMS2WMV:FAILED:unable to connect video pins :0x{0:X}", hr);
Cleanup();
return false;
}
string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv");
if (!AddWmAsfWriter(outputFilename, quality, standard)) return false;
Log.Info("DVRMS2WMV: start pre-run");
mediaControl = graphBuilder as IMediaControl;
mediaSeeking = bufferSource as IStreamBufferMediaSeeking;
mediaEvt = graphBuilder as IMediaEventEx;
mediaPos = graphBuilder as IMediaPosition;
//get file duration
long lTime = 5 * 60 * 60;
lTime *= 10000000;
long pStop = 0;
hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
if (hr == 0)
{
long lStreamPos;
mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position
m_dDuration = lStreamPos;
lTime = 0;
mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop),
AMSeekingSeekingFlags.NoPositioning);
}
double duration = m_dDuration / 10000000d;
Log.Info("DVRMS2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration));
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("DVRMS2WMV:FAILED:unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
int maxCount = 20;
while (true)
{
long lCurrent;
mediaSeeking.GetCurrentPosition(out lCurrent);
double dpos = (double)lCurrent;
dpos /= 10000000d;
System.Threading.Thread.Sleep(100);
if (dpos >= 2.0d) break;
maxCount--;
if (maxCount <= 0) break;
}
Log.Info("DVRMS2WMV: pre-run done");
Log.Info("DVRMS2WMV: Get duration of movie");
mediaControl.Stop();
FilterState state;
mediaControl.GetState(500, out state);
GC.Collect();
GC.Collect();
GC.Collect();
GC.WaitForPendingFinalizers();
Log.Info("DVRMS2WMV: reconnect mpeg2 video codec->ASF WM Writer");
graphBuilder.RemoveFilter(fileWriterbase);
if (!AddWmAsfWriter(outputFilename, quality, standard)) return false;
Log.Info("DVRMS2WMV: Start transcoding");
hr = mediaControl.Run();
if (hr != 0)
{
Log.Error("DVRMS2WMV:FAILED:unable to start graph :0x{0:X}", hr);
Cleanup();
return false;
}
}
catch (Exception e)
{
// TODO: Handle exceptions.
Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message);
return false;
}
return true;
}
示例10: 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"));
//.........这里部分代码省略.........
示例11: MediaPreviewer_Load
private void MediaPreviewer_Load(object sender, EventArgs e)
{
statusBarPanel1.Text = "Buffering !! Please Wait";
CleanUp();
Console.WriteLine("download finished");
m_objFilterGraph = new FilgraphManager();
try
{
m_objFilterGraph.RenderFile(fileName);
}
catch (Exception ex)
{
return;
}
m_objBasicAudio = m_objFilterGraph as IBasicAudio;
try
{
m_objVideoWindow = m_objFilterGraph as IVideoWindow;
m_objVideoWindow.Owner = (int) panel1.Handle;
m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
catch (Exception)
{
m_objVideoWindow = null;
}
m_objMediaEvent = m_objFilterGraph as IMediaEvent;
m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
m_objMediaEventEx.SetNotifyWindow((int) this.Handle,WM_GRAPHNOTIFY, 0);
m_objMediaPosition = m_objFilterGraph as IMediaPosition;
m_objMediaControl = m_objFilterGraph as IMediaControl;
this.Text = "SMART MediaPreviewer";
m_objMediaControl.Run();
m_CurrentStatus = MediaStatus.Running;
UpdateStatusBar();
UpdateToolBar();
}
示例12: PlayeMusic
public void PlayeMusic(string url)
{
try
{
if (myMediaControl != null)
{
myMediaControl.Stop();
}
//InitPlayer();
myFilterGraph = new FilgraphManager();
//PublicInterFace.LogErro(url);
myFilterGraph.RenderFile(url);
myBasicAudio = myFilterGraph as IBasicAudio;
myMediaEvent = myFilterGraph as IMediaEvent;
myMediaPosition = myFilterGraph as IMediaPosition;
myMediaControl = myFilterGraph as IMediaControl;
myBasicAudio.Volume = 100;
//int ai = myBasicAudio.Volume;
myMediaControl.Run();
//IsPlay = true;
//BaseInovke(new MethodInvoker(delegate()
//{
// playerControl.StratAnti();
// playTimer.Start();
//}));
}
catch (Exception ex)
{
//PublicInterFace.LogErro("发生异常:\r\n" + ex.Message + "\r\n" + ex.StackTrace);
//BaseInovke(new MethodInvoker(delegate()
//{
// playTimer.Stop();
// playerControl.StopAnti();
// IsPlay = false;
// nowPlayMusic.Text = "播放失败!请尝试换个链接或者下载!";
//}));
}
}
示例13: FileLoad
//Мотод для загрузки видео файла.
public void FileLoad(string sfile, Panel vPanel)
{
CleanUp();
graphBuilder = (IGraphBuilder) new FilterGraph();
mediaControl = graphBuilder as IMediaControl;
mediaPosition = graphBuilder as IMediaPosition;
videoWindow = graphBuilder as IVideoWindow;
basicAudio = graphBuilder as IBasicAudio;
ddColor.lBrightness = 0;
ddColor.lContrast = 0;
ddColor.lGamma = 0;
ddColor.lSaturation = 0;
graphBuilder.RenderFile(sfile, null);
videoWindow.put_Owner(vPanel.Handle);
videoWindow.put_WindowStyle(WindowStyle.Child
| WindowStyle.ClipSiblings
| WindowStyle.ClipChildren);
videoWindow.SetWindowPosition(vPanel.ClientRectangle.Left,
vPanel.ClientRectangle.Top,
vPanel.ClientRectangle.Width,
vPanel.ClientRectangle.Height);
mediaControl.Run();
CurrentStatus = mStatus.Play;
mediaPosition.get_Duration(out mediaTimeSeconds);
allSeconds = (int)mediaTimeSeconds;
}
示例14: Init
/// <summary>
/// Worker thread that captures the images
/// </summary>
private void Init()
{
try
{
log.Trace("Start worker thread");
// Create the main graph
_graph = Activator.CreateInstance(Type.GetTypeFromCLSID(FilterGraph)) as IGraphBuilder;
// Create the webcam source
_sourceObject = FilterInfo.CreateFilter(_monikerString);
// Create the grabber
_grabber = Activator.CreateInstance(Type.GetTypeFromCLSID(SampleGrabber)) as ISampleGrabber;
_grabberObject = _grabber as IBaseFilter;
// Add the source and grabber to the main graph
_graph.AddFilter(_sourceObject, "source");
_graph.AddFilter(_grabberObject, "grabber");
using (AMMediaType mediaType = new AMMediaType())
{
mediaType.MajorType = MediaTypes.Video;
mediaType.SubType = MediaSubTypes.RGB32;
_grabber.SetMediaType(mediaType);
if (_graph.Connect(_sourceObject.GetPin(PinDirection.Output, 0), _grabberObject.GetPin(PinDirection.Input, 0)) >= 0)
{
if (_grabber.GetConnectedMediaType(mediaType) == 0)
{
// During startup, this code can be too fast, so try at least 3 times
int retryCount = 0;
bool succeeded = false;
while ((retryCount < 3) && !succeeded)
{
// Tried again
retryCount++;
try
{
// Retrieve the grabber information
VideoInfoHeader header = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.FormatPtr, typeof(VideoInfoHeader));
_capGrabber.Width = header.BmiHeader.Width;
_capGrabber.Height = header.BmiHeader.Height;
// Succeeded
succeeded = true;
}
catch
{
// Trace
log.InfoFormat("Failed to retrieve the grabber information, tried {0} time(s)", retryCount);
// Sleep
Thread.Sleep(50);
}
}
}
}
_graph.Render(_grabberObject.GetPin(PinDirection.Output, 0));
_grabber.SetBufferSamples(false);
_grabber.SetOneShot(false);
_grabber.SetCallback(_capGrabber, 1);
log.Trace("_grabber set up");
// Get the video window
IVideoWindow wnd = (IVideoWindow)_graph;
wnd.put_AutoShow(false);
wnd = null;
// Create the control and run
_control = (IMediaControl)_graph;
_control.Run();
log.Trace("control runs");
// Wait for the stop signal
//while (!_stopSignal.WaitOne(0, true))
//{
// Thread.Sleep(10);
//}
}
}catch (Exception ex)
{
// Trace
log.Debug(ex);
Release();
}
}
示例15: openFile
public void openFile(string filename)
{
CleanUp();
m_objFilterGraph = new FilgraphManager();
m_objFilterGraph.RenderFile(filename);
try
{
m_objVideoWindow = m_objFilterGraph as IVideoWindow;
m_objVideoWindow.Owner = (int)panel1.Handle;
m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
panel1.ClientRectangle.Top,
panel1.ClientRectangle.Width,
panel1.ClientRectangle.Height);
}
catch (Exception)
{
m_objVideoWindow = null;
}
m_objMediaEvent = m_objFilterGraph as IMediaEvent;
m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
m_objMediaEventEx.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0);
m_objMediaPosition = m_objFilterGraph as IMediaPosition;
m_objMediaControl = m_objFilterGraph as IMediaControl;
this.Text = "Preview - [" + filename + "]";
m_objMediaControl.Run();
m_objMediaControl.Pause();
UpdateStatusBar();
UpdateToolBar();
}