Skip to content
Snippets Groups Projects
Commit 21bc527e authored by Pierre Lamot's avatar Pierre Lamot Committed by Jean-Baptiste Kempf
Browse files

qt: fetch medialib media from url on ML thread

parent e84a9ae0
No related branches found
No related tags found
Loading
......@@ -55,14 +55,30 @@ QHash<int, QByteArray> MLUrlModel::roleNames() const
void MLUrlModel::addAndPlay( const QString &url )
{
ml_unique_ptr<vlc_ml_media_t> s{vlc_ml_get_media_by_mrl( m_ml, qtu( url ))};
if (!s)
s.reset(vlc_ml_new_stream( m_ml, qtu( url ) ));
if (!s)
return;
MLItemId itemId( s->i_id, VLC_ML_PARENT_UNKNOWN );
m_mediaLib->addAndPlay(itemId);
emit resetRequested();
struct Ctx{
bool succeed = false;
MLItemId itemId;
};
m_mediaLib->runOnMLThread<Ctx>(this,
//ML thread
[url](vlc_medialibrary_t* ml, Ctx& ctx){
ml_unique_ptr<vlc_ml_media_t> s{vlc_ml_get_media_by_mrl( ml, qtu( url ))};
if (!s)
s.reset(vlc_ml_new_stream( ml, qtu( url ) ));
if (!s)
return;
ctx.succeed = true;
ctx.itemId = MLItemId( s->i_id, VLC_ML_PARENT_UNKNOWN );
},
//UI Thread
[this](quint64, Ctx& ctx){
if (!ctx.succeed)
return;
m_mediaLib->addAndPlay(ctx.itemId);
emit resetRequested();
});
}
vlc_ml_sorting_criteria_t MLUrlModel::roleToCriteria(int role) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment