本文整理汇总了C#中IMediaPosition类 的典型用法代码示例。如果您正苦于以下问题:C# IMediaPosition类的具体用法?C# IMediaPosition怎么用?C# IMediaPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMediaPosition类 属于命名空间,在下文中一共展示了IMediaPosition类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildGraph
private void BuildGraph(string fileName)
{
int hr = 0;
try
{
graphBuilder = (IFilterGraph2)new FilterGraph();
mediaControl = (IMediaControl)graphBuilder;
mediaSeeking = (IMediaSeeking)graphBuilder;
mediaPosition = (IMediaPosition)graphBuilder;
vmr9 = (IBaseFilter)new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
hr = graphBuilder.RenderFile(fileName, null);
DsError.ThrowExceptionForHR(hr);
}
catch (Exception e)
{
CloseInterfaces();
MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
开发者ID:andrewjswan, 项目名称:mvcentral, 代码行数:28, 代码来源:framegrabber.cs
示例2: Play
//TODO Fichier déjà utilisé.... surement par Quartz. Essayer de libérer les ressources de la librairie
public void Play(Guid id, byte[] file)
{
objFilterGraph = new FilgraphManager();
audio = (IBasicAudio) objFilterGraph;
//pb d'accès concurrenciel
string path = ConfigurationManager.AppSettings["MediaCache"] + id + ".mp3";
File.WriteAllBytes(path, file);
objFilterGraph.RenderFile(path);
objMediaPosition = objFilterGraph as IMediaPosition;
objFilterGraph.Run();
tmProgressionFlux = new Timer(1000) { Enabled = true };
tmProgressionFlux.Elapsed += TmProgressionFluxTick;
TimerResume();
}
开发者ID:naturalevolution, 项目名称:MonkeyMusicCloud, 代码行数:18, 代码来源:DirectPlayer.cs
示例3: 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();
}
开发者ID:szopenfx, 项目名称:code, 代码行数:47, 代码来源:GraphicalInterface2.cs
示例4: Initialize
public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
{
const int wsChild = 0x40000000;
string ext = System.IO.Path.GetExtension(videoFileName).ToLower();
bool isAudio = ext == ".mp3" || ext == ".wav" || ext == ".wma" || ext == ".ogg" || ext == ".mpa" || ext == ".m4a" || ext == ".ape" || ext == ".aiff" || ext == ".flac" || ext == ".acc" || ext == ".mka";
OnVideoLoaded = onVideoLoaded;
OnVideoEnded = onVideoEnded;
VideoFileName = videoFileName;
_owner = ownerControl;
_quartzFilgraphManager = new FilgraphManager();
_quartzFilgraphManager.RenderFile(VideoFileName);
if (!isAudio)
{
_quartzVideo = _quartzFilgraphManager as IVideoWindow;
_quartzVideo.Owner = (int)ownerControl.Handle;
_quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height);
_quartzVideo.WindowStyle = wsChild;
}
//Play();
if (!isAudio)
(_quartzFilgraphManager as IBasicVideo).GetVideoSize(out _sourceWidth, out _sourceHeight);
_owner.Resize += OwnerControlResize;
_mediaPosition = (IMediaPosition)_quartzFilgraphManager;
if (OnVideoLoaded != null)
{
_videoLoader = new BackgroundWorker();
_videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted;
_videoLoader.DoWork += VideoLoaderDoWork;
_videoLoader.RunWorkerAsync();
}
OwnerControlResize(this, null);
_videoEndTimer = new Timer { Interval = 500 };
_videoEndTimer.Tick += VideoEndTimerTick;
_videoEndTimer.Start();
if (!isAudio)
_quartzVideo.MessageDrain = (int)ownerControl.Handle;
}
开发者ID:ItsJustSean, 项目名称:subtitleedit, 代码行数:45, 代码来源:QuartsPlayer.cs
示例5: PlayMovieInWindow
//.........这里部分代码省略.........
if (EVRControl == null)
{
//Ищем рендерер и ВКЛЮЧАЕМ соблюдение аспекта (рендерер сам подгонит картинку под размер окна, с учетом аспекта)
IsRendererARFixed = false;
IBaseFilter filter = null;
graphBuilder.FindFilterByName("Video Renderer", out filter);
if (filter != null)
{
IVMRAspectRatioControl vmr = filter as IVMRAspectRatioControl;
if (vmr != null)
{
DsError.ThrowExceptionForHR(vmr.SetAspectRatioMode(VMRAspectRatioMode.LetterBox));
IsRendererARFixed = true;
}
}
else
{
graphBuilder.FindFilterByName("Video Mixing Renderer 9", out filter);
if (filter != null)
{
IVMRAspectRatioControl9 vmr9 = filter as IVMRAspectRatioControl9;
if (vmr9 != null)
{
DsError.ThrowExceptionForHR(vmr9.SetAspectRatioMode(VMRAspectRatioMode.LetterBox));
IsRendererARFixed = true;
}
}
}
}
else
IsRendererARFixed = true;
this.mediaControl = (IMediaControl)this.graphBuilder;
this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
this.mediaPosition = (IMediaPosition)this.graphBuilder;
this.videoWindow = (EVRControl == null) ? this.graphBuilder as IVideoWindow : null;
this.basicVideo = (EVRControl == null) ? this.graphBuilder as IBasicVideo : null;
this.basicAudio = this.graphBuilder as IBasicAudio;
this.basicAudio.put_Volume(VolumeSet);
this.CheckIsAudioOnly();
if (!this.isAudioOnly)
{
if (videoWindow != null)
{
hr = this.videoWindow.put_Owner(this.source.Handle);
DsError.ThrowExceptionForHR(hr);
hr = this.videoWindow.put_MessageDrain(this.source.Handle);
DsError.ThrowExceptionForHR(hr);
hr = this.videoWindow.put_WindowStyle(DirectShowLib.WindowStyle.Child | DirectShowLib.WindowStyle.ClipSiblings | DirectShowLib.WindowStyle.ClipChildren);
DsError.ThrowExceptionForHR(hr);
}
this.MoveVideoWindow();
}
else
{
if (VHost != null)
{
VHost.Dispose();
VHost = null;
VHandle = IntPtr.Zero;
VHostElement.Child = null;
VHostElement.Visibility = Visibility.Collapsed;
}
}
hr = this.mediaEventEx.SetNotifyWindow(this.source.Handle, WMGraphNotify, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);
//Восстанавливаем старую позицию
if (mediaload == MediaLoad.Update && oldpos != TimeSpan.Zero)
{
if (NaturalDuration >= oldpos)
{
hr = mediaPosition.put_CurrentPosition(oldpos.TotalSeconds);
DsError.ThrowExceptionForHR(hr);
}
}
//Восстанавливаем старый PlayState
if (mediaload == MediaLoad.Update && (oldplaystate == PlayState.Paused || oldplaystate == PlayState.Stopped))
{
hr = this.mediaControl.Pause();
DsError.ThrowExceptionForHR(hr);
this.currentState = PlayState.Paused;
this.SetPlayIcon();
}
else
{
hr = this.mediaControl.Run();
DsError.ThrowExceptionForHR(hr);
this.currentState = PlayState.Running;
this.SetPauseIcon();
}
AddFiltersToMenu();
}
开发者ID:MaksHDR, 项目名称:xvid4psp, 代码行数:101, 代码来源:MainWindow.xaml.cs
示例6: GetInterfaces
//.........这里部分代码省略.........
graphBuilder.Render(pins[0]);
}
}
#endregion
// Connect DVB subtitle filter pins in the graph
if (_mpegDemux != null && enableDvbSubtitles == true)
{
IMpeg2Demultiplexer demuxer = _mpegDemux as IMpeg2Demultiplexer;
hr = demuxer.CreateOutputPin(GetTSMedia(), "Pcr", out _pinPcr);
if (hr == 0)
{
Log.Info("RTSPPlayer:_pinPcr OK");
IPin pDemuxerPcr = DsFindPin.ByName(_mpegDemux, "Pcr");
IPin pSubtitlePcr = DsFindPin.ByName(_subtitleFilter, "Pcr");
hr = graphBuilder.Connect(pDemuxerPcr, pSubtitlePcr);
}
else
{
Log.Info("RTSPPlayer:Failed to create _pinPcr in demuxer:{0:X}", hr);
}
hr = demuxer.CreateOutputPin(GetTSMedia(), "Subtitle", out _pinSubtitle);
if (hr == 0)
{
Log.Info("RTSPPlayer:_pinSubtitle OK");
IPin pDemuxerSubtitle = DsFindPin.ByName(_mpegDemux, "Subtitle");
IPin pSubtitle = DsFindPin.ByName(_subtitleFilter, "In");
hr = graphBuilder.Connect(pDemuxerSubtitle, pSubtitle);
}
else
{
Log.Info("RTSPPlayer:Failed to create _pinSubtitle in demuxer:{0:X}", hr);
}
hr = demuxer.CreateOutputPin(GetTSMedia(), "PMT", out _pinPMT);
if (hr == 0)
{
Log.Info("RTSPPlayer:_pinPMT OK");
IPin pDemuxerSubtitle = DsFindPin.ByName(_mpegDemux, "PMT");
IPin pSubtitle = DsFindPin.ByName(_subtitleFilter, "PMT");
hr = graphBuilder.Connect(pDemuxerSubtitle, pSubtitle);
}
else
{
Log.Info("RTSPPlayer:Failed to create _pinPMT in demuxer:{0:X}", hr);
}
}
if (IsRadio == false)
{
if (!VMR9Util.g_vmr9.IsVMR9Connected)
{
//VMR9 is not supported, switch to overlay
Log.Info("RTSPPlayer: vmr9 not connected");
_mediaCtrl = null;
Cleanup();
return false;
}
VMR9Util.g_vmr9.SetDeinterlaceMode();
}
_mediaCtrl = (IMediaControl)graphBuilder;
mediaEvt = (IMediaEventEx)graphBuilder;
_mediaSeeking = (IMediaSeeking)graphBuilder;
mediaPos = (IMediaPosition)graphBuilder;
basicAudio = graphBuilder as IBasicAudio;
//DirectShowUtil.SetARMode(graphBuilder,AspectRatioMode.Stretched);
DirectShowUtil.EnableDeInterlace(graphBuilder);
if (VMR9Util.g_vmr9 != null)
{
m_iVideoWidth = VMR9Util.g_vmr9.VideoWidth;
m_iVideoHeight = VMR9Util.g_vmr9.VideoHeight;
}
if (audioRendererFilter != null)
{
Log.Info("RTSPPlayer9:set reference clock");
IMediaFilter mp = graphBuilder as IMediaFilter;
IReferenceClock clock = audioRendererFilter as IReferenceClock;
hr = mp.SetSyncSource(null);
hr = mp.SetSyncSource(clock);
Log.Info("RTSPPlayer9:set reference clock:{0:X}", hr);
}
Log.Info("RTSPPlayer: graph build successfull");
return true;
}
catch (Exception ex)
{
Error.SetError("Unable to play movie", "Unable build graph for VMR9");
Log.Error("RTSPPlayer:exception while creating DShow graph {0} {1}", ex.Message, ex.StackTrace);
CloseInterfaces();
return false;
}
}
开发者ID:MediaPortal, 项目名称:MediaPortal-1, 代码行数:101, 代码来源:RTSPPlayer.cs
示例7: GetDVDInterfaces
//.........这里部分代码省略.........
catch (Exception ex)
{
string strEx = ex.Message;
}
Guid riid;
if (_dvdInfo == null)
{
riid = typeof(IDvdInfo2).GUID;
hr = _dvdGraph.GetDvdInterface(riid, out comobj);
if (hr < 0)
{
Marshal.ThrowExceptionForHR(hr);
}
_dvdInfo = (IDvdInfo2)comobj;
comobj = null;
}
if (_dvdCtrl == null)
{
riid = typeof(IDvdControl2).GUID;
hr = _dvdGraph.GetDvdInterface(riid, out comobj);
if (hr < 0)
{
Marshal.ThrowExceptionForHR(hr);
}
_dvdCtrl = (IDvdControl2)comobj;
comobj = null;
}
_mediaCtrl = (IMediaControl)_graphBuilder;
_mediaEvt = (IMediaEventEx)_graphBuilder;
_basicAudio = _graphBuilder as IBasicAudio;
_mediaPos = (IMediaPosition)_graphBuilder;
_mediaSeek = (IMediaSeeking)_graphBuilder;
_mediaStep = (IVideoFrameStep)_graphBuilder;
_basicVideo = _graphBuilder as IBasicVideo2;
_videoWin = _graphBuilder as IVideoWindow;
// disable Closed Captions!
IBaseFilter baseFilter;
_graphBuilder.FindFilterByName("Line 21 Decoder", out baseFilter);
if (baseFilter == null)
{
_graphBuilder.FindFilterByName("Line21 Decoder", out baseFilter);
}
if (baseFilter != null)
{
_line21Decoder = (IAMLine21Decoder)baseFilter;
if (_line21Decoder != null)
{
AMLine21CCState state = AMLine21CCState.Off;
hr = _line21Decoder.SetServiceState(state);
if (hr == 0)
{
logger.Info("DVDPlayer:Closed Captions disabled");
}
else
{
logger.Info("DVDPlayer:failed 2 disable Closed Captions");
}
}
}
/*
// get video window
if (_videoWin==null)
{
riid = typeof( IVideoWindow ).GUID;
hr = _dvdGraph.GetDvdInterface( ref riid, out comobj );
if( hr < 0 )
Marshal.ThrowExceptionForHR( hr );
_videoWin = (IVideoWindow) comobj; comobj = null;
}
*/
// GetFrameStepInterface();
DirectShowUtil.SetARMode(_graphBuilder, arMode);
DirectShowUtil.EnableDeInterlace(_graphBuilder);
//m_ovMgr = new OVTOOLLib.OvMgrClass();
//m_ovMgr.SetGraph(_graphBuilder);
return true;
}
catch (Exception)
{
//MessageBox.Show( this, "Could not get interfaces\r\n" + ee.Message, "DVDPlayer.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop );
CloseDVDInterfaces();
return false;
}
finally
{
if (comobj != null)
{
DirectShowUtil.ReleaseComObject(comobj);
}
comobj = null;
}
}
开发者ID:andrewjswan, 项目名称:mvcentral, 代码行数:101, 代码来源:Grabber.cs
示例8: Initialize
public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
{
const int wsChild = 0x40000000;
var extension = System.IO.Path.GetExtension(videoFileName);
if (extension == null)
{
return;
}
string ext = extension.ToLower();
bool isAudio = ext == ".mp3" || ext == ".wav" || ext == ".wma" || ext == ".m4a";
OnVideoLoaded = onVideoLoaded;
OnVideoEnded = onVideoEnded;
VideoFileName = videoFileName;
owner = ownerControl;
quartzFilgraphManager = new FilgraphManager();
quartzFilgraphManager.RenderFile(VideoFileName);
if (!isAudio)
{
quartzVideo = quartzFilgraphManager as IVideoWindow;
if (quartzVideo != null)
{
quartzVideo.Owner = (int)ownerControl.Handle;
quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height);
quartzVideo.WindowStyle = wsChild;
}
}
//Play();
if (!isAudio)
{
var basicVideo = quartzFilgraphManager as IBasicVideo;
if (basicVideo != null)
{
basicVideo.GetVideoSize(out sourceWidth, out sourceHeight);
}
}
owner.Resize += OwnerControlResize;
mediaPosition = (IMediaPosition)quartzFilgraphManager;
if (OnVideoLoaded != null)
{
videoLoader = new BackgroundWorker();
videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted;
videoLoader.DoWork += VideoLoaderDoWork;
videoLoader.RunWorkerAsync();
}
OwnerControlResize(this, null);
videoEndTimer = new Timer { Interval = 500 };
videoEndTimer.Tick += VideoEndTimerTick;
videoEndTimer.Start();
if (isAudio)
{
return;
}
if (quartzVideo != null)
{
quartzVideo.MessageDrain = (int)ownerControl.Handle;
}
}
开发者ID:AsenTahchiyski, 项目名称:SoftUni-Projects, 代码行数:67, 代码来源:QuartsPlayer.cs
示例9: InitInterfaces
/// <summary>
/// Initialises DirectShow interfaces
/// </summary>
private void InitInterfaces()
{
var comtype = Type.GetTypeFromCLSID(Clsid.FilterGraph);
if (comtype == null)
throw new NotSupportedException("DirectX (8.1 or higher) not installed?");
var fg = Activator.CreateInstance(comtype);
m_graphBuilder = (IGraphBuilder)fg;
m_mediaControl = (IMediaControl)fg;
m_mediaEvent = (IMediaEventEx)fg;
m_mediaSeeking = (IMediaSeeking)fg;
m_mediaPosition = (IMediaPosition)fg;
m_basicAudio = (IBasicAudio)fg;
fg = null;
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:19, 代码来源:VideoPlayer.cs
示例10: InitInterfaces
/// <summary>
/// Initialises DirectShow interfaces
/// </summary>
private void InitInterfaces()
{
fg = new FilterGraph();
gb = (IGraphBuilder)fg;
mc = (IMediaControl)fg;
me = (IMediaEventEx)fg;
ms = (IMediaSeeking)fg;
mp = (IMediaPosition)fg;
}
开发者ID:Ryuzaki, 项目名称:RVTN, 代码行数:12, 代码来源:VideoPlayer.cs
示例11: BuildGraph
private void BuildGraph()
{
int hr;
try
{
lblTotalTime.Text = mvs.PlayTime.ToString();
TimeSpan tt = TimeSpan.Parse(mvs.PlayTime);
DateTime dt = new DateTime(tt.Ticks);
lblTotalTime.Text = String.Format("{0:HH:mm:ss}", dt);
if (mvs.LocalMedia[0].IsDVD)
{
mediaToPlay = mvs.LocalMedia[0];
MediaState mediaState = mediaToPlay.State;
if (mediaState == MediaState.NotMounted)
{
MountResult result = mediaToPlay.Mount();
}
string videoPath = mediaToPlay.GetVideoPath();
if (videoPath != null)
FirstPlayDvd(videoPath);
else
FirstPlayDvd(mvs.LocalMedia[0].File.FullName);
// Add delegates for Windowless operations
AddHandlers();
MainForm_ResizeMove(null, null);
}
else
{
_graphBuilder = (IFilterGraph2)new FilterGraph();
_rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder);
_mediaCtrl = (IMediaControl)_graphBuilder;
_mediaSeek = (IMediaSeeking)_graphBuilder;
_mediaPos = (IMediaPosition)_graphBuilder;
_mediaStep = (IVideoFrameStep)_graphBuilder;
_vmr9Filter = (IBaseFilter)new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
AddHandlers();
MainForm_ResizeMove(null, null);
hr = _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Render 9");
AddPreferedCodecs(_graphBuilder);
DsError.ThrowExceptionForHR(hr);
hr = _graphBuilder.RenderFile(mvs.LocalMedia[0].File.FullName, null);
DsError.ThrowExceptionForHR(hr);
}
}
catch (Exception e)
{
CloseDVDInterfaces();
logger.ErrorException("An error occured during the graph building : \r\n\r\n",e);
}
}
开发者ID:andrewjswan, 项目名称:mvcentral, 代码行数:57, 代码来源:Grabber.cs
示例12: OpenStream
//
// Starts playback for the selected stream at the specified time
//
int OpenStream(string videopath, double videotime)
{
double td; // store stream duration;
int hr = 0;
// animate bt logo
// logo_webbrowser.Refresh();
// cover overlay options with video or not
// if overlay is active
////////if (OverlayButton.Checked) // Overlay button config - Melek
////////{
//////// VideoPanel.Width = VideoPlayerPanel.Width - OverlayPanel.Width;
//////// OverlayBar.Location = new System.Drawing.Point(-1, -1); ;
//////// OverlayBar.Text = ">";
////////}
////////else
////////// if overlay is not active
////////{
//////// VideoPanel.Width = VideoPlayerPanel.Width - OverlayBar.Width;
//////// OverlayBar.Location = new System.Drawing.Point(OverlayPanel.Width - OverlayBar.Width - 1, -1); ;
//////// OverlayBar.Text = "<";
////////}
filename = videopath;
try//Melek
{
if (filename == string.Empty)
return -1;
// this.graphBuilder = (IGraphBuilder)new FilterGraph();
this.graphBuilder = (IFilterGraph2)new FilterGraph();
// We manually add the VMR (video mixer/renderer) filter so that we can set it into "mixing" mode.
// That is needed so that the VMR will deinterlace before playing back
VideoMixingRenderer vmr = new VideoMixingRenderer(); //Tom's deinterlace changes
graphBuilder.AddFilter((IBaseFilter)vmr, "vmr");//Tom's deinterlace changes
IVMRFilterConfig vmrConfig = vmr as IVMRFilterConfig;//Tom's deinterlace changes
int nRet = vmrConfig.SetNumberOfStreams(1);//Tom's deinterlace changes
// BuildVideoGraph(videopath); //No more overlay - Melek
hr = this.graphBuilder.RenderFile(filename, null);//MELek - instead of calling BuildVideoGraph function call RenderFile function directly
DsError.ThrowExceptionForHR(hr);//Melek
// QueryInterface for DirectShow interfaces
this.mediaControl = (IMediaControl)this.graphBuilder;
this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
this.mediaPosition = (IMediaPosition)this.graphBuilder;
// Query for video interfaces, which may not be relevant for audio files
this.videoWindow = this.graphBuilder as IVideoWindow;
this.basicVideo = this.graphBuilder as IBasicVideo;
// Query for audio interfaces, which may not be relevant for video-only files
this.basicAudio = this.graphBuilder as IBasicAudio;
// Is this an audio-only file (no video component)?
CheckVisibility();
// Have the graph signal event via window callbacks for performance
hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);
//if (!this.isAudioOnly)
//{
// Setup the video window
hr = this.videoWindow.put_Owner(this.VideoPanel.Handle);
DsError.ThrowExceptionForHR(hr);
hr = this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
DsError.ThrowExceptionForHR(hr);
hr = InitVideoWindow(1, 1);
DsError.ThrowExceptionForHR(hr);
GetFrameStepInterface();
//}
//else
//{
// Initialize the default player size
// hr = InitPlayerWindow();
// DsError.ThrowExceptionForHR(hr);
//EnablePlaybackMenu(true, MediaType.Audio);
//}
// Complete window initialization
//CheckSizeMenu(menuFileSizeNormal);
//this.isFullScreen = false;
this.currentPlaybackRate = 1.0;
#if DEBUG
rot = new DsROTEntry(this.graphBuilder);
#endif
//.........这里部分代码省略.........
开发者ID:mguthrie777, 项目名称:demo-newstuff, 代码行数:101, 代码来源:GUI.cs
示例13: 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();
}
}
}
开发者ID:Surigoma, 项目名称:Electronicboard, 代码行数:68, 代码来源:Movie.cs
示例14: StartCapture
//.........这里部分代码省略.........
// Get the SampleGrabber interface
sampGrabber = (ISampleGrabber) new SampleGrabber();
// Start building the graph
hr = capGraph.SetFiltergraph(m_FilterGraph);
DsError.ThrowExceptionForHR(hr);
// Add the video source
hr = m_FilterGraph.AddSourceFilter(txtAviFileName.Text, "File Source (Async.)", out capFilter);
DsError.ThrowExceptionForHR(hr);
//add AVI Decompressor
IBaseFilter pAVIDecompressor = (IBaseFilter) new AVIDec();
hr = m_FilterGraph.AddFilter(pAVIDecompressor, "AVI Decompressor");
DsError.ThrowExceptionForHR(hr);
IBaseFilter ffdshow;
try
{
// Create Decoder filter COM object (ffdshow video decoder)
Type comtype = Type.GetTypeFromCLSID(new Guid("{04FE9017-F873-410E-871E-AB91661A4EF7}"));
if (comtype == null)
throw new NotSupportedException("Creating ffdshow video decoder COM object fails.");
object comobj = Activator.CreateInstance(comtype);
ffdshow = (IBaseFilter) comobj; // error ocurrs! raised exception
comobj = null;
}
catch
{
CustomMessageBox.Show("Please install/reinstall ffdshow");
return;
}
hr = m_FilterGraph.AddFilter(ffdshow, "ffdshow");
DsError.ThrowExceptionForHR(hr);
//
IBaseFilter baseGrabFlt = (IBaseFilter) sampGrabber;
ConfigureSampleGrabber(sampGrabber);
// Add the frame grabber to the graph
hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
IBaseFilter vidrender = (IBaseFilter) new VideoRenderer();
hr = m_FilterGraph.AddFilter(vidrender, "Render");
DsError.ThrowExceptionForHR(hr);
IPin captpin = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);
IPin ffdpinin = DsFindPin.ByName(ffdshow, "In");
IPin ffdpinout = DsFindPin.ByName(ffdshow, "Out");
IPin samppin = DsFindPin.ByName(baseGrabFlt, "Input");
hr = m_FilterGraph.Connect(captpin, ffdpinin);
DsError.ThrowExceptionForHR(hr);
hr = m_FilterGraph.Connect(ffdpinout, samppin);
DsError.ThrowExceptionForHR(hr);
FileWriter filewritter = new FileWriter();
IFileSinkFilter filemux = (IFileSinkFilter) filewritter;
//filemux.SetFileName("test.avi",);
//hr = capGraph.RenderStream(null, MediaType.Video, capFilter, null, vidrender);
// DsError.ThrowExceptionForHR(hr);
SaveSizeInfo(sampGrabber);
// setup buffer
if (m_handle == IntPtr.Zero)
m_handle = Marshal.AllocCoTaskMem(m_stride*m_videoHeight);
// tell the callback to ignore new images
m_PictureReady = new ManualResetEvent(false);
m_bGotOne = false;
m_bRunning = false;
timer1 = new Thread(timer);
timer1.IsBackground = true;
timer1.Start();
m_mediaextseek = m_FilterGraph as IAMExtendedSeeking;
m_mediapos = m_FilterGraph as IMediaPosition;
m_mediaseek = m_FilterGraph as IMediaSeeking;
double length = 0;
m_mediapos.get_Duration(out length);
trackBar_mediapos.Minimum = 0;
trackBar_mediapos.Maximum = (int) length;
Start();
}
else
{
MessageBox.Show("File does not exist");
}
}
开发者ID:duyisu, 项目名称:MissionPlanner, 代码行数:101, 代码来源:OSDVideo.cs
示例15: 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;
}
}
开发者ID:RoseySoft, 项目名称:Whistle, 代码行数:34, 代码来源:Form1.cs
示例16: PlayMovieInWindow
private void PlayMovieInWindow(string filename)
{
int hr = 0;
if (filename == string.Empty)
return;
this.graphBuilder = (IGraphBuilder) new FilterGraph();
// Have the graph builder construct its the appropriate graph automatically
hr = this.graphBuilder.RenderFile(filename, null);
DsError.ThrowExceptionForHR(hr);
// QueryInterface for DirectShow interfaces
this.mediaControl = (IMediaControl) this.graphBuilder;
this.mediaEventEx = (IMediaEventEx) this.graphBuilder;
this.mediaSeeking = (IMediaSeeking) this.graphBuilder;
this.mediaPosition = (IMediaPosition) this.graphBuilder;
// Query for video interfaces, which may not be relevant for audio files
this.videoWindow = this.graphBuilder as IVideoWindow;
this.basicVideo = this.graphBuilder as IBasicVideo;
// Query for audio interfaces, which may not be relevant for video-only files
this.basicAudio = this.graphBuilder as IBasicAudio;
// Is this an audio-only file (no video component)?
CheckVisibility();
// Have the graph signal event via window callbacks for performance
hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);
if (!this.isAudioOnly)
{
// Setup the video window
hr = this.videoWindow.put_Owner(this.Handle);
DsError.ThrowExceptionForHR(hr);
hr = this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
DsError.ThrowExceptionForHR(hr);
hr = InitVideoWindow(1, 1);
DsError.ThrowExceptionForHR(hr);
GetFrameStepInterface();
}
else
{
// Initialize the default player size and enable playback menu items
hr = InitPlayerWindow();
DsError.ThrowExceptionForHR(hr);
EnablePlaybackMenu(true, MediaType.Audio);
}
// Complete window initialization
CheckSizeMenu(menuFileSizeNormal);
this.isFullScreen = false;
this.currentPlaybackRate = 1.0;
UpdateMainTitle();
#if DEBUG
rot = new DsROTEntry(this.graphBuilder);
#endif
this.Focus();
// Run the graph to play the media file
hr = this.mediaControl.Run();
DsError.ThrowExceptionForHR(hr);
this.currentState=PlayState.Running;
}
开发者ID:coolsula, 项目名称:vidplaycorder, 代码行数:74, 代码来源:MainForm.cs
示例17: AudioAnimate
// Methods
internal AudioAnimate(string prefix, string localname, string ns, SvgDocument doc)
: base(prefix, localname, ns, doc)
{
this.m_objFilterGraph = null;
this.m_objBasicAudio = null;
this.m_objMediaEvent = null;
this.m_objMediaEventEx = null;
this.m_objMediaPosition = null;
this.m_objMediaControl = null;
this.fillColor = Color.Khaki;
this.fileName = string.Empty;
this.m_CurrentStatus = MediaStatus.None;
this.timer = new Timer();
this.oldtime = 0f;
this.timertime = 0f;
this.timer.Interval = 100;
this.timer.Tick += new EventHandler(this.TimerTick);
}
开发者ID:EdgarEDT, 项目名称:myitoppsp, 代码行数:19, 代码来源:AudioAnimate.cs
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19247| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:10004| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8334| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8703| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8649| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9675| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8635| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:8008| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8671| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7542| 2022-11-06
请发表评论