garkimasera / vlc-rs

Rust bindings for libVLC media framework.
MIT License
66 stars 18 forks source link

Send trait not implemented #16

Open Luis-Licea opened 2 years ago

Luis-Licea commented 2 years ago

Hello,

I am trying to create a simple app that plays radio stations. I can't create a GUI that plays a radio station from an URL because the main thread becomes busy playing music, so the GUI freezes and becomes irresponsive. Clicking the stop button does not work. The solution is to create another thread that plays the radio station, while the main thread stays responsive to button clicks. The problem then becomes sharing those button clicks with the other thread so it knows to stop playing music or change volume. Sharing values between threads is not allowed directly because it could lead to a data race. I tried using Arc and Mutex to access the Instance, Media, and Media Player objects thread-safely, but this did not work because none of those objects implement the Send trait.

Any idea on how I could access all the methods of the MediaPlayer so I can stop the player or change the volume from the main thread while the media player is running on another thread?