Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Add path property to set VlcPlayer media source as path rather than as MRL #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions QmlVlcPlayerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ QString QmlVlcPlayerProxy::get_vlcVersion()
return QString::fromLatin1( libvlc_get_version() );
}

void QmlVlcPlayerProxy::play( const QString& mrl )
void QmlVlcPlayerProxy::play( const QString& mrl, bool is_path /*= false*/ )
{
vlc::playlist_player_core& p = player();

p.clear_items();

int item = p.add_media( mrl.toUtf8().data(), 0, 0, 0, 0 );
int item = p.add_media( mrl.toUtf8().data(), 0, 0, 0, 0, is_path );
if( item >= 0) {
p.play( item );
}
Expand Down Expand Up @@ -313,6 +313,17 @@ void QmlVlcPlayerProxy::set_mrl( const QString& mrl )
play( mrl );
}

QString QmlVlcPlayerProxy::get_path()
{
std::string path = player().current_media().mrl();
return QString::fromUtf8( path.data(), path.size() );
}

void QmlVlcPlayerProxy::set_path( const QString& path )
{
play( path, true );
}

bool QmlVlcPlayerProxy::get_playing()
{
return player().is_playing();
Expand Down
6 changes: 5 additions & 1 deletion QmlVlcPlayerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class QmlVlcPlayerProxy
Q_PROPERTY( State state READ get_state NOTIFY stateChanged )

Q_PROPERTY( QString mrl READ get_mrl WRITE set_mrl )
Q_PROPERTY( QString path READ get_path WRITE set_path )
Q_PROPERTY( double position READ get_position WRITE set_position NOTIFY mediaPlayerPositionChanged )
Q_PROPERTY( double time READ get_time WRITE set_time NOTIFY mediaPlayerTimeChanged )
Q_PROPERTY( unsigned volume READ get_volume WRITE set_volume NOTIFY volumeChanged )
Expand All @@ -92,7 +93,7 @@ class QmlVlcPlayerProxy
//QML Api
QString get_vlcVersion();

Q_INVOKABLE void play( const QString& mrl );
Q_INVOKABLE void play( const QString& mrl, bool is_path = false );
Q_INVOKABLE void play();
Q_INVOKABLE void pause();
Q_INVOKABLE void togglePause();
Expand All @@ -104,6 +105,9 @@ class QmlVlcPlayerProxy
QString get_mrl();
void set_mrl( const QString& mrl );

QString get_path();
void set_path( const QString& path );

bool get_playing();

double get_length();
Expand Down