[vlc-devel] CLI Bindings : AccessViolationException on player

Developer developer at noknok.net
Thu Dec 10 16:25:48 CET 2009


Damien wrote:

> Running my program directly from commandline (so it uses the Microsoft 
> Framework), behavior is the same (native crash) also with the bad 
> string behavior.
>
>
> I hope there is enough details to help find a start of 
> debugging/workaround idea.
>
> Thanks
>
> Damien
>   

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,""))



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=c:\\ffmpeg\\VlcLog.txt" };
   
    try {
        if (_VLCDebug) {
            _VLC = new VideoLan.VideoLanClient(_VLCPath, optsdebug);
        }
        else {
            _VLC = new VideoLan.VideoLanClient(_VLCPath, opts);
        }
       
        _IsRunning = true;
    }
    catch (Exception ex) {
        _IsRunning = false;
    }
       
    return _IsRunning;
}

private void PlayVideo(string fn, intptr playwindow, string EncodeOption)
{
   
   
    VideoLan.VlcMedia mx = _vlc.NewMedia(fn);
    if (!string.isNullOrEmpty(encodeoption)) mx.AddOption(EncodeOptions);
   
    //Note: You may set playwindow = intptr.zero, which will just encode 
your file/not show it
    VideoLan.VlcMediaPlayer cplayer = _VLC.NewMediaPlayer(playwindow);
    cplayer.Load(mx);
    mx.Dispose();
   
       
    cPlayer.Play();
}




More information about the vlc-devel mailing list