Git Product home page Git Product logo

Comments (13)

jfgbaker avatar jfgbaker commented on June 12, 2024 1

Ok - figured out a work around - in VlcMediaPlayer.cs (in Core) simply wrap the methods in a new thread. It must be a thread deadlock. i.e.:
public void Play()
{
Thread thread = new Thread(delegate() { Manager.Play(myMediaPlayer); });
thread.Start();
}

i voided setmedia as well, didnt need the return.

    public void SetMedia(VlcMedia media)
    {
        Thread thread = new Thread(delegate() { Manager.SetMediaToMediaPlayer(myMediaPlayer, media.MediaInstance); });
        thread.Start();
    }

...

hope this helps...

from vlc.dotnet.

yapa69 avatar yapa69 commented on June 12, 2024

+1, I need this functionality too

from vlc.dotnet.

jfgbaker avatar jfgbaker commented on June 12, 2024

+1, I really need this as well - any work around?

from vlc.dotnet.

wolf-germany avatar wolf-germany commented on June 12, 2024

Maybe same issue as in #81. EndReached event (temporary) unregister all events and "reset" the media player core instance.

from vlc.dotnet.

jeremyVignelles avatar jeremyVignelles commented on June 12, 2024

Deadlocks will appear if you call Vlc methods from vlc callbacks. You should call that from another thread, as jfgbaker suggested, or with ThreadPool.QueueUserWorkItem() or Task.Run.

Closing this as a solution has been provided, feel free to reopen if needed.

from vlc.dotnet.

zandiarash avatar zandiarash commented on June 12, 2024

Hi every body
I’m using the latest version and I’m not calling Vlc methods from vlc callbacks
But my application freezes when I want to set another media from my play list.
I should mention that my application should play stream not video file.
I also tried these :

vlcControl.Play(currStream);

And

new System.Threading.Thread(()=>
{
    vlcControl.Play(currStream);
}).Start();

And

new System.Threading.Tasks.Task(() =>
{
    vlcControl.Play(currStream);
}).Start();

And

System.Threading.ThreadPool.QueueUserWorkItem((a) =>
{
    vlcControl.Play(currStream);
});

but still freeze.

from vlc.dotnet.

jeremyVignelles avatar jeremyVignelles commented on June 12, 2024

The deadlock you are experiencing does not seem to be related to this issue. You might have a deadlock elsewhere in your code. Can you create a minimal project to reproduce that and send that on github so that we can have a look?

from vlc.dotnet.

zandiarash avatar zandiarash commented on June 12, 2024

Yes as you said my issue was not related to this thread.
When I was creating a minimal project I realized that my problem was related to this part of code :

private void vlcControl_LengthChanged(object sender,
Vlc.DotNet.Core.VlcMediaPlayerLengthChangedEventArgs e)
        {
            Action act = new Action(() =>
            {
                label2.Text = TimeSpan.FromMilliseconds(vlcControl.Length).ToString("hh\\:mm\\:ss");
            });
            if (this.InvokeRequired)
                this.Invoke(act);
            else
                act();
        }

I was calling calling Vlc methods from vlc callback (sorry, my mistake).
I changed my code to this :

private void vlcControl_LengthChanged(object sender, Vlc.DotNet.Core.VlcMediaPlayerLengthChangedEventArgs e)
        {
            Action act = new Action(() =>
            {
                label2.Text = TimeSpan.FromMilliseconds(vlcControl.Length).ToString("hh\\:mm\\:ss");
            });
            new Task(() =>
            {
                if (this.InvokeRequired)
                    this.Invoke(act);
                else
                    act();
            }).Start();
        }

And my problem is solved now.
Thanks alot and apologize my spam

from vlc.dotnet.

jeremyVignelles avatar jeremyVignelles commented on June 12, 2024

Any reason you don't use the Length from your e parameter? that would save a call to libvlc

from vlc.dotnet.

zandiarash avatar zandiarash commented on June 12, 2024

Any reason you don't use the Length from your e parameter? that would save a call to libvlc

do you mean this ?

e.NewLength

I will try it.
Thanks for your suggestion.

why

e.NewLength

is float but

vlcControl.Length

is long ?

from vlc.dotnet.

jeremyVignelles avatar jeremyVignelles commented on June 12, 2024

You're right, I changed the type in Vlc.DotNet.Core.Interops, but didn't propagate the change to Vlc.DotNet.Forms
The event is wrong, everything should be typed as Long

from vlc.dotnet.

jeremyVignelles avatar jeremyVignelles commented on June 12, 2024

Can you make a PR for that?

from vlc.dotnet.

zandiarash avatar zandiarash commented on June 12, 2024

Can you make a PR for that?

Sure, I will do it with pleasure.

from vlc.dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.