本文整理汇总了C#中IMedia.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# IMedia.Parse方法的具体用法?C# IMedia.Parse怎么用?C# IMedia.Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMedia
的用法示例。
在下文中一共展示了IMedia.Parse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Play
public void Play(string filename)
{
if (InvokeRequired)
Invoke(new PlayDelegate(Play), filename);
else
{
_needsSize = _filename != filename;
_filename = filename;
_mMedia = _mFactory.CreateMedia<IMedia>(filename);
_mMedia.Events.DurationChanged += EventsDurationChanged;
_mMedia.Events.StateChanged += EventsStateChanged;
_mMedia.Events.ParsedChanged += Events_ParsedChanged;
_mPlayer.Open(_mMedia);
_mMedia.Parse(true);
_mPlayer.Play();
string[] parts = filename.Split('\\');
string fn = parts[parts.Length - 1];
FilesFile ff =
((MainForm) Owner).GetCameraWindow(ObjectID).FileList.FirstOrDefault(p => p.Filename.EndsWith(fn));
if (ff!=null)
vNav.Render(ff);
}
}
示例2: button1_Click
private void button1_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == true)
{
textBlock1.Text = ofd.FileName;
m_media = m_factory.CreateMedia<IMediaFromFile>(ofd.FileName);
m_media.Events.DurationChanged += new EventHandler<MediaDurationChange>(Events_DurationChanged);
m_media.Events.StateChanged += new EventHandler<MediaStateChange>(Events_StateChanged);
m_player.Open(m_media);
m_media.Parse(true);
}
}
示例3: Start
/// <summary>
/// Start video source.
/// </summary>
///
/// <remarks>Starts video source and return execution to caller. Video source
/// object creates background thread and notifies about new frames with the
/// help of <see cref="NewFrame"/> event.</remarks>
///
/// <exception cref="ArgumentException">Video source is not specified.</exception>
///
public void Start()
{
if (!VlcHelper.VlcInstalled)
return;
Isstopping = false;
if (!IsRunning && !_starting)
{
_starting = true;
// check source
if (string.IsNullOrEmpty(_source))
throw new ArgumentException("Video source is not specified.");
DisposePlayer();
_mFactory = new MediaPlayerFactory(false);
_mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
_mPlayer.Events.PlayerPlaying += EventsPlayerPlaying;
_mPlayer.Events.PlayerStopped += EventsPlayerStopped;
_mPlayer.Events.PlayerEncounteredError += EventsPlayerEncounteredError;
_mMedia = _mFactory.CreateMedia<IMedia>(_source, Arguments);
_mPlayer.Open(_mMedia);
GC.KeepAlive(_mFactory);
GC.KeepAlive(_mPlayer);
GC.KeepAlive(_mMedia);
_needsSetup = true;
var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
_mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
var ac = new AudioCallbacks { SoundCallback = SoundCallback };
_mPlayer.CustomAudioRenderer.SetCallbacks(ac);
_mPlayer.CustomRenderer.SetFormat(new BitmapFormat(FormatWidth, FormatHeight, ChromaType.RV24));
_mPlayer.CustomRenderer.SetCallback(FrameCallback);
_mMedia.Parse(true);
_framesReceived = 0;
_mPlayer.Play();
}
}
示例4: button3_Click
private void button3_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBox1.Text))
{
m_media = m_factory.CreateMedia<IMedia>(textBox1.Text);
m_media.Events.DurationChanged += new EventHandler<MediaDurationChange>(Events_DurationChanged);
m_media.Events.StateChanged += new EventHandler<MediaStateChange>(Events_StateChanged);
m_media.Events.ParsedChanged += new EventHandler<MediaParseChange>(Events_ParsedChanged);
m_player.Open(m_media);
m_media.Parse(true);
m_player.Play();
}
else
{
errorProvider1.SetError(textBox1, "Please select media path first !");
}
}
示例5: button6_Click
private void button6_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBox1.Text))
{
// string output = ":sout=file:abc.mp4";
// string output = ":sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=abc.mp4}";//,dst=display}
// string output1 = ":demux=dump :demuxdump-file=output.mp4";
string output = ":sout=#transcode{demux=dump}:duplicate{dst=file{dst=output1.mp4}";//,dst=display}
m_media = m_factory.CreateMedia<IMedia>(textBox1.Text, output);
m_media.Events.DurationChanged += new EventHandler<MediaDurationChange>(Events_DurationChanged);
m_media.Events.StateChanged += new EventHandler<MediaStateChange>(Events_StateChanged);
m_media.Events.ParsedChanged += new EventHandler<MediaParseChange>(Events_ParsedChanged);
m_player.Open(m_media);
m_media.Parse(true);
m_player.Play();
}
else
{
errorProvider1.SetError(textBox1, "Please select media path first !");
}
}
示例6: Play
public void Play(string filename, string titleText)
{
if (InvokeRequired)
Invoke(new PlayDelegate(Play), filename, titleText);
else
{
if (!File.Exists(filename))
{
MessageBox.Show(this, LocRm.GetString("FileNotFound")+Environment.NewLine + filename);
return;
}
_needsSize = _filename != filename;
_filename = filename;
lock (_lock)
{
_mMedia = _mFactory.CreateMedia<IMediaFromFile>(filename);
_mMedia.Events.DurationChanged += EventsDurationChanged;
_mMedia.Events.StateChanged += EventsStateChanged;
_mMedia.Events.ParsedChanged += Events_ParsedChanged;
try
{
_mPlayer.Open(_mMedia);
_mMedia.Parse(true);
}
catch (Exception ex)
{
MainForm.LogExceptionToFile(ex);
MessageBox.Show(this, LocRm.GetString("CouldNotOpen")+Environment.NewLine + filename);
return;
}
_mPlayer.Play();
}
string[] parts = filename.Split('\\');
string fn = parts[parts.Length - 1];
FilesFile ff = null;
if (fn.EndsWith(".mp3") || fn.EndsWith(".wav"))
{
var vl = ((MainForm)Owner).GetVolumeLevel(ObjectID);
if (vl != null)
{
ff = vl.FileList.FirstOrDefault(p => p.Filename.EndsWith(fn));
}
vNav.IsAudio = true;
pnlMovie.BackgroundImage = Properties.Resources.ispy1audio;
}
else
{
var cw = ((MainForm)Owner).GetCameraWindow(ObjectID);
if (cw!=null) {
ff = cw.FileList.FirstOrDefault(p => p.Filename.EndsWith(fn));
}
vNav.IsAudio = false;
pnlMovie.BackgroundImage = Properties.Resources.ispy1;
}
if (ff!=null)
vNav.Init(ff);
Text = titleText;
}
}
示例7: Start
/// <summary>
/// Start audio source.
/// </summary>
///
/// <remarks>Starts audio source and return execution to caller. audio source
/// object creates background thread and notifies about new frames with the
/// help of <see cref="DataAvailable"/> event.</remarks>
///
/// <exception cref="ArgumentException">audio source is not specified.</exception>
///
public void Start()
{
if (!VlcHelper.VlcInstalled)
return;
if (!IsRunning)
{
// check source
if (string.IsNullOrEmpty(_source))
throw new ArgumentException("Audio source is not specified.");
DisposePlayer();
_mFactory = new MediaPlayerFactory(false);
_mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
_mPlayer.Events.PlayerPlaying += EventsPlayerPlaying;
_mPlayer.Events.PlayerStopped += EventsPlayerStopped;
_mPlayer.Events.PlayerEncounteredError += EventsPlayerEncounteredError;
string[] args = Arguments.Trim(',').Split(Environment.NewLine.ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
List<String> inargs = args.ToList();
inargs.Add(":sout=#transcode{vcodec=none}:Display");
_mMedia = _mFactory.CreateMedia<IMedia>(_source, inargs.ToArray());
_mPlayer.Open(_mMedia);
GC.KeepAlive(_mFactory);
GC.KeepAlive(_mPlayer);
GC.KeepAlive(_mMedia);
_needsSetup = true;
var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
_mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
var ac = new AudioCallbacks {SoundCallback = SoundCallback};
_mPlayer.CustomAudioRenderer.SetCallbacks(ac);
_mMedia.Events.ParsedChanged += EventsParsedChanged;
_mMedia.Parse(true);
_mPlayer.Play();
}
}
示例8: WorkerThread
private void WorkerThread()
{
bool file = false;
try
{
if (File.Exists(_source))
{
file = true;
}
}
catch
{
// ignored
}
if (_mFactory == null)
{
var args = new List<string>
{
"-I",
"dumy",
"--ignore-config",
"--no-osd",
"--disable-screensaver",
"--plugin-path=./plugins",
"--novideo"
};
if (file)
args.Add("--file-caching=3000");
try
{
var l2 = args.ToList();
l2.AddRange(_arguments);
l2 = l2.Distinct().ToList();
_mFactory = new MediaPlayerFactory(l2.ToArray());
}
catch (Exception ex)
{
Logger.LogExceptionToFile(ex, "VLC Audio");
Logger.LogMessageToFile("VLC arguments are: " + String.Join(",", args.ToArray()), "VLC Audio");
Logger.LogMessageToFile("Using default VLC configuration.", "VLC Audio");
_mFactory = new MediaPlayerFactory(args.ToArray());
}
GC.KeepAlive(_mFactory);
}
_mMedia = file ? _mFactory.CreateMedia<IMediaFromFile>(_source) : _mFactory.CreateMedia<IMedia>(_source);
_mMedia.Events.DurationChanged += EventsDurationChanged;
_mMedia.Events.StateChanged += EventsStateChanged;
try
{
_mPlayer?.Dispose();
}
catch
{
// ignored
}
_mPlayer = null;
_mPlayer = _mFactory.CreatePlayer<IVideoPlayer>();
_mPlayer.Events.TimeChanged += EventsTimeChanged;
var fc = new Func<SoundFormat, SoundFormat>(SoundFormatCallback);
_mPlayer.CustomAudioRenderer.SetFormatCallback(fc);
var ac = new AudioCallbacks { SoundCallback = SoundCallback };
_mPlayer.CustomAudioRenderer.SetCallbacks(ac);
_mPlayer.CustomAudioRenderer.SetExceptionHandler(Handler);
GC.KeepAlive(_mPlayer);
_needsSetup = true;
_stopping = false;
_mPlayer.Open(_mMedia);
_mMedia.Parse(true);
_mPlayer.Delay = 0;
_framesReceived = 0;
Duration = Time = 0;
LastFrame = DateTime.MinValue;
//check if file source (isseekable in _mPlayer is not reliable)
Seekable = false;
try
{
var p = Path.GetFullPath(_mMedia.Input);
Seekable = !string.IsNullOrEmpty(p);
}
catch (Exception)
{
Seekable = false;
}
_mPlayer.WindowHandle = IntPtr.Zero;
_mPlayer.Play();
_stopEvent.WaitOne();
if (!Seekable && !_stopRequested)
//.........这里部分代码省略.........
示例9: VideoWindow
//public VideoWindow()
private VideoWindow(FileInfo imgSrc, FileInfo videoSrc)
{
InitializeComponent();
this.Width = SystemParameters.PrimaryScreenWidth;
this.Height = SystemParameters.PrimaryScreenHeight;
this.Left = 0;
this.Top = 0;
// this.Topmost = true;
//imgSrc = new FileInfo(@"C:\Users\Administrator\Videos\thumbnails\b.jpg");
//videoSrc = new FileInfo(@"C:\Users\Administrator\Videos\b.mp4");
img = new BitmapImage(new Uri(imgSrc.FullName));
fileName = videoSrc.FullName;
//根据分辨率不同,调整DetialWindow出现的位置
if (this.Width > 1300)
{
size = SystemParameters.PrimaryScreenWidth*0.415;
}
else if (this.Width < 1300 && this.Width > 1000)
{
size = SystemParameters.PrimaryScreenWidth*0.415;
}
if (img.Width >= img.Height)
{
w = size;
h = size/img.Width*img.Height;
}
else
{
h = size;
w = size/img.Height*img.Width;
}
gd.Background = new ImageBrush(img);
stdStart = (Storyboard) this.Resources["start"];
stdEnd = (Storyboard) this.Resources["end"];
stdEnd2 = (Storyboard) this.Resources["end_2"];
stdVideoFinish = (Storyboard) Resources["VideoFinish"];
stdStart.Completed += (a, b) =>
{
//stdMiddle.Begin();
TimeSplit.Visibility = Visibility.Visible;
var datPrs = new DoubleAnimation(0, 600, new Duration(TimeSpan.FromMilliseconds(1000)));
process.BeginAnimation(ProgressBar.WidthProperty, datPrs);
///播放视频
m_media = m_factory.CreateMedia<IMediaFromFile>(fileName);
m_media.Events.DurationChanged += Events_DurationChanged;
m_media.Events.StateChanged += Events_StateChanged;
m_player.Open(m_media);
m_media.Parse(true);
m_player.Play();
//System.Drawing.Size s = m_player.GetVideoSize(0);
//m_player.TakeSnapShot(0, @"C:\");
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(1000);
timer.Tick += (c, d) =>
{
gd.Background = null;
timer.Stop();
};
timer.Start();
};
stdEnd.Completed += (c, d) =>
{
CloseAnmit();
stdEnd2.Begin();
};
stdEnd2.Completed += (e, f) => { this.Close(); };
this.Loaded += MainWindow_Loaded;
m_factory = new MediaPlayerFactory();
m_player = m_factory.CreatePlayer<IVideoPlayer>();
m_videoImage.Initialize(m_player.CustomRendererEx);
m_player.Events.PlayerPositionChanged +=
new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);
}