[vlc-devel] CLI Bindings : AccessViolationException on player
Developer
developer at noknok.net
Thu Dec 10 17:32:10 CET 2009
Damien wrote:
>
> Try this code please:
>
> (1. _VLC is a local global/private variable)
> (2. Change the appropriate opts items to match yours)
> (3. Call Initialize)
> (4. Call PlayVideo (filename,windowhandle,""))
>
>
> I have copied your code (altering it to match bindings in vlc git).
> Here it is :
> --8<----8<----8<----8<----8<----8<--
> public partial class Form1 : Form
> {
> private VLC _VLC;
> private bool _VLCDebug;
> private string _VLCPath;
> private string _VLCPluginPath;
> private bool _IsRunning = false;
>
> internal Form1(string vlcPath, string vlcPlugins)
> {
> InitializeComponent();
> this._VLCPath = vlcPath;
> this._VLCPluginPath = vlcPlugins;
> }
>
> private void Form1_Shown(object sender, EventArgs e)
> {
> this.Initialize(true);
> this.PlayVideo("D:\\a.avi", this.Handle, string.Empty);
> }
>
> public bool Initialize(bool DebugOn)
> {
> _VLCDebug = DebugOn;
> string[] opts = { "-I", "dummy", "--plugin-path=" +
> _VLCPluginPath, "--one-instance" };
> string[] optsdebug = { "-I", "dummy", "--plugin-path=" +
> _VLCPluginPath, "-vvv", "--extraintf=logger",
> "--logfile=D:\\VlcLog.txt" };
> try
> {
> if (_VLCDebug)
> {
> _VLC = new VLC(optsdebug);
> }
> else
> {
> _VLC = new VLC(opts);
> }
> _IsRunning = true;
> }
> catch (Exception ex)
> {
> _IsRunning = false;
> }
> return _IsRunning;
> }
>
> private void PlayVideo(string fn, IntPtr playwindow, string
> EncodeOption)
> {
> Media mx = new Media(_VLC, fn);
> if (!string.IsNullOrEmpty(EncodeOption))
> mx.AddOptions(EncodeOption, true);
> //Note: You may set playwindow = intptr.zero, which will
> just encode your file/not show it
> Player player = new Player(_VLC);
> player.Media = mx;
> this.Text = mx.Location;
> mx.Dispose();
> player.Play();
> }
> }
> --8<----8<----8<----8<----8<----8<--
>
>
You didnt transpose properly.....
I see a couple issues:
_VLC = new VideoLan.VideoLanClient(_VLCPath, optsdebug); <-- I specify
the path, you do not
VideoLan.VlcMedia mx = _vlc.NewMedia(fn);
and
VideoLan.VlcMediaPlayer cplayer = _VLC.NewMediaPlayer(playwindow);
I derive my COM objects directly from the instantiated _VLC.
You derive them as NEW and point to _VLC... I am not sure if this could
be posing an issue or not (one would think not, but then again it is
just code...... and could have a bug)
**** and lastly... the big one: *****
Player player = new Player(_VLC);
you should be using playwindow(the handle to your window) here:
Player player = new Player(playwindow);
shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20091210/7833ffe7/attachment.html>
More information about the vlc-devel
mailing list