Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VlcPlayer not be ready #150

Closed
jasondavidcarr opened this issue Aug 17, 2016 · 5 comments
Closed

VlcPlayer not be ready #150

jasondavidcarr opened this issue Aug 17, 2016 · 5 comments
Labels

Comments

@jasondavidcarr
Copy link

Hi Higankanshi, very much appreciate the awesome work you're doing here with this library. We're running into a bug where we're getting this error randomly and occasionally:

System.InvalidOperationException: VlcPlayer not be ready, if you want to use VlcPlay no in XAML, please read this Wiki: "https://github.com/higankanshi/Meta.Vlc/wiki/Use-VlcPlayer-with-other-controls".
at (VlcPlayer , IntPtr& , UInt32& , UInt32& , UInt32& , UInt32& , UInt32& )
at Meta.Vlc.Wpf.VlcPlayer.VideoFormatCallback(IntPtr& opaque, UInt32& chroma, UInt32& width, UInt32& height, UInt32& pitches, UInt32& lines)

We are in fact using the VlcPlayer in XAML. Here is the code I am using to initialize VlcPlayer:

` var options = new string[]
{
"-I",
"--dummy-quiet",
"--ignore-config",
"--no-video-title",
"--no-sub-autodetect-file"
};

            this.vlcPlayer = new VlcPlayer();
            this.vlcPlayer.LibVlcPath = Path.Combine(System.Windows.Forms.Application.StartupPath, Environment.Is64BitOperatingSystem ? @"VLC\x64" : @"VLC\x86");
            this.vlcPlayer.EndBehavior = EndBehavior.Repeat;
            this.vlcPlayer.VlcOption = options;
            this.vlcPlayer.HorizontalContentAlignment = HorizontalAlignment.Center;
            this.vlcPlayer.VerticalContentAlignment = VerticalAlignment.Center;
            this.Grid.Children.Add(this.vlcPlayer);

`

In theory, this code should always be running before any videos are presented or displayed, because I have this code in the constructor of my ImageVideoView XAML class. However, I'm still randomly getting this error from time to time, because somehow DisplayThreadDispatcher is null in the VideoFormatCallback method in rare circumstances. I'm not sure why or how this is happening really.

I very much appreciate any help you can provide.

Thanks,
Jason

@jasondavidcarr
Copy link
Author

Hi again, sorry to bombard you here; but I have some more information that might help. It's worth noting that I've also run into some Null Reference Exceptions in the VideoDisplayCallback method in VlcPlayer.Events.cs. I ended up adding this to the top of that method:

if (_context == null || DisplayThreadDispatcher == null) { return; }

What seems to be happening is that if the VLC video ever gets hidden after it is loaded up in XAML, then things tend to go haywire because the _context and/or the DisplayThreadDispatcher end up being NULL. I expect that this is somehow related to the above issue as well.

Bear in mind that my implementation is likely more complicated than usual because I am using transition animations to switch between videos and doing lots of hiding and showing various different videos at different times. It's an involved implementation; I will say that the last "Fix VlcPlayer can't unload and reload." commit did a lot of things to help fix the situation, so I really appreciate that. Hopefully we can resolve the rest of the issues.

Thanks again,
Jason

@devkanro
Copy link
Owner

Check the last commit, I'm not sure, I just reproduce once.

@jasondavidcarr
Copy link
Author

Killer, thank you! On it.

@jasondavidcarr
Copy link
Author

From what I can immediately tell I think you've nailed it. Thank you, thank you, thank you. I'll speak up again if we run into any additional issues.

@devkanro
Copy link
Owner

You're welcome, if you have any issues, let me know, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants