[vlc-commits] [Git][videolan/vlc][master] 4 commits: medialib: read restore config values through input object

Jean-Baptiste Kempf gitlab at videolan.org
Sat Jun 12 10:42:53 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
d67f6b87 by Prince Gupta at 2021-06-12T09:44:28+00:00
medialib: read restore config values through input object

- - - - -
904f3257 by Prince Gupta at 2021-06-12T09:44:28+00:00
qt: take media options as const reference

- - - - -
e4925bfe by Prince Gupta at 2021-06-12T09:44:28+00:00
qml: auto resume playbacks from video recent view

closes #25587

- - - - -
304dcb43 by Prince Gupta at 2021-06-12T09:44:28+00:00
qml: fix double view push for player

fixes #25592

- - - - -


11 changed files:

- modules/gui/qt/dialogs/dialogs_provider.cpp
- modules/gui/qt/dialogs/open/open.cpp
- modules/gui/qt/maininterface/main_interface.cpp
- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/medialibrary/medialib.cpp
- modules/gui/qt/medialibrary/medialib.hpp
- modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
- modules/gui/qt/medialibrary/qml/VideoGridItem.qml
- modules/gui/qt/menus/qml_menu_wrapper.cpp
- modules/gui/qt/playlist/media.hpp
- src/player/medialib.c


Changes:

=====================================
modules/gui/qt/dialogs/dialogs_provider.cpp
=====================================
@@ -548,7 +548,7 @@ void DialogsProvider::simpleOpenDialog(bool start)
     urls.sort();
     QVector<vlc::playlist::Media> medias;
     for( const QString& mrl : urls)
-        medias.push_back( vlc::playlist::Media{mrl, nullptr, nullptr} );
+        medias.push_back( vlc::playlist::Media{mrl, QString {}} );
     if (!medias.empty())
         THEMPL->append(medias, start);
 }
@@ -576,7 +576,7 @@ void DialogsProvider::openUrlDialog()
         url = qfu(uri);
         free( uri );
     }
-    QVector<vlc::playlist::Media> medias = { {url, nullptr, nullptr} };
+    QVector<vlc::playlist::Media> medias = { {url, QString {}} };
     THEMPL->append(medias, !oud.shouldEnqueue());
 }
 
@@ -591,7 +591,7 @@ static void openDirectory( qt_intf_t *p_intf, bool go )
     QString uri = DialogsProvider::getDirectoryDialog( p_intf );
     if( !uri.isEmpty() )
     {
-        QVector<vlc::playlist::Media> medias = { {uri, nullptr, nullptr} };
+        QVector<vlc::playlist::Media> medias = { {uri, QString {}} };
         THEMPL->append(medias, go);
     }
 }
@@ -766,7 +766,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
         QVector<vlc::playlist::Media> outputMedias;
         std::transform(outputMRLs.cbegin(), outputMRLs.cend(), std::back_inserter(outputMedias), [&](const QString& mrl) {
             QString title = "Converting " + mrl;
-            return vlc::playlist::Media(mrl, title, &options);
+            return vlc::playlist::Media(mrl, title, options);
         });
         THEMPL->append(outputMedias, true);
     }


=====================================
modules/gui/qt/dialogs/open/open.cpp
=====================================
@@ -375,7 +375,7 @@ void OpenDialog::enqueue( bool b_enqueue )
     /* Take options from the UI, not from what we stored */
     QStringList optionsList = getOptions().split( " :" );
     for( const QString& mrl : itemsMRL)
-        medias.push_back( vlc::playlist::Media{mrl, nullptr, &optionsList} );
+        medias.push_back( vlc::playlist::Media{mrl, nullptr, optionsList} );
     if (!medias.empty())
         THEMPL->append(medias, !b_enqueue);
 }


=====================================
modules/gui/qt/maininterface/main_interface.cpp
=====================================
@@ -662,7 +662,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
             }
 #endif
             if( mrl.length() > 0 )
-                medias.push_back( vlc::playlist::Media{ mrl, nullptr, nullptr });
+                medias.push_back( vlc::playlist::Media{ mrl, QString {} });
         }
     }
 
@@ -673,7 +673,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
         QUrl(mimeData->text()).isValid() )
     {
         QString mrl = toURI( mimeData->text() );
-        medias.push_back( vlc::playlist::Media{ mrl, nullptr, nullptr });
+        medias.push_back( vlc::playlist::Media{ mrl, QString {} });
     }
     if (!medias.empty())
         THEMPL->append(medias, b_play);


=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -406,7 +406,8 @@ Widgets.NavigableFocusScope {
                 target: player
                 onHasVideoOutputChanged: {
                     if (player.hasVideoOutput && mainInterface.hasEmbededVideo) {
-                        g_mainDisplay.showPlayer()
+                        if (history.current.view !== "player")
+                            g_mainDisplay.showPlayer()
                     } else {
                         _showMiniPlayer = false;
                     }


=====================================
modules/gui/qt/medialibrary/medialib.cpp
=====================================
@@ -40,20 +40,20 @@ MediaLib::MediaLib(qt_intf_t *_intf, QObject *_parent)
     m_threadPool.setMaxThreadCount(4);
 }
 
-void MediaLib::addToPlaylist(const QString& mrl, const QStringList* options)
+void MediaLib::addToPlaylist(const QString& mrl, const QStringList &options)
 {
     vlc::playlist::Media media{ mrl, mrl, options };
     m_intf->p_mainPlaylistController->append( {media}, false );
 }
 
-void MediaLib::addToPlaylist(const QUrl& mrl, const QStringList* options)
+void MediaLib::addToPlaylist(const QUrl& mrl, const QStringList &options)
 {
     vlc::playlist::Media media{ mrl.toString(QUrl::None), mrl.fileName(), options };
     m_intf->p_mainPlaylistController->append( {media} , false );
 }
 
 // A specific item has been asked to be added to the playlist
-void MediaLib::addToPlaylist(const MLItemId & itemId, const QStringList* options)
+void MediaLib::addToPlaylist(const MLItemId & itemId, const QStringList &options)
 {
     //invalid item
     if (itemId.id == 0)
@@ -85,7 +85,7 @@ void MediaLib::addToPlaylist(const MLItemId & itemId, const QStringList* options
     }
 }
 
-void MediaLib::addToPlaylist(const QVariantList& itemIdList, const QStringList* options)
+void MediaLib::addToPlaylist(const QVariantList& itemIdList, const QStringList &options)
 {
     for (const QVariant& varValue: itemIdList)
     {
@@ -109,7 +109,7 @@ void MediaLib::addToPlaylist(const QVariantList& itemIdList, const QStringList*
 
 // A specific item has been asked to be played,
 // so it's added to the playlist and played
-void MediaLib::addAndPlay(const MLItemId & itemId, const QStringList* options )
+void MediaLib::addAndPlay(const MLItemId & itemId, const QStringList &options )
 {
     if (itemId.id == 0)
         return;
@@ -139,20 +139,20 @@ void MediaLib::addAndPlay(const MLItemId & itemId, const QStringList* options )
     }
 }
 
-void MediaLib::addAndPlay(const QString& mrl, const QStringList* options)
+void MediaLib::addAndPlay(const QString& mrl, const QStringList &options)
 {
     vlc::playlist::Media media{ mrl, mrl, options };
     m_intf->p_mainPlaylistController->append( {media}, true );
 }
 
-void MediaLib::addAndPlay(const QUrl& mrl, const QStringList* options)
+void MediaLib::addAndPlay(const QUrl& mrl, const QStringList &options)
 {
     vlc::playlist::Media media{ mrl.toString(QUrl::None), mrl.fileName(), options };
     m_intf->p_mainPlaylistController->append( {media}, true );
 }
 
 
-void MediaLib::addAndPlay(const QVariantList& itemIdList, const QStringList* options)
+void MediaLib::addAndPlay(const QVariantList& itemIdList, const QStringList &options)
 {
     bool b_start = true;
     for (const QVariant& varValue: itemIdList)
@@ -187,7 +187,7 @@ void MediaLib::addAndPlay(const QVariantList& itemIdList, const QStringList* opt
     }
 }
 
-void MediaLib::insertIntoPlaylist(const size_t index, const QVariantList &itemIds, const QStringList *options)
+void MediaLib::insertIntoPlaylist(const size_t index, const QVariantList &itemIds, const QStringList &options)
 {
     QVector<vlc::playlist::Media> medias;
     for ( const auto &id : itemIds )


=====================================
modules/gui/qt/medialibrary/medialib.hpp
=====================================
@@ -47,16 +47,16 @@ class MediaLib : public QObject
 public:
     MediaLib(qt_intf_t* _intf, QObject* _parent = nullptr );
 
-    Q_INVOKABLE void addToPlaylist(const MLItemId &itemId, const QStringList* options = nullptr);
-    Q_INVOKABLE void addToPlaylist(const QString& mrl, const QStringList* options = nullptr);
-    Q_INVOKABLE void addToPlaylist(const QUrl& mrl, const QStringList* options = nullptr);
-    Q_INVOKABLE void addToPlaylist(const QVariantList& itemIdList, const QStringList* options = nullptr);
-
-    Q_INVOKABLE void addAndPlay(const MLItemId &itemId, const QStringList* options = nullptr);
-    Q_INVOKABLE void addAndPlay(const QString& mrl, const QStringList* options = nullptr);
-    Q_INVOKABLE void addAndPlay(const QUrl& mrl, const QStringList* options = nullptr);
-    Q_INVOKABLE void addAndPlay(const QVariantList&itemIdList, const QStringList* options = nullptr);
-    Q_INVOKABLE void insertIntoPlaylist(size_t index, const QVariantList &itemIds /*QList<MLParentId>*/, const QStringList *options = nullptr);
+    Q_INVOKABLE void addToPlaylist(const MLItemId &itemId, const QStringList &options = {});
+    Q_INVOKABLE void addToPlaylist(const QString& mrl, const QStringList &options = {});
+    Q_INVOKABLE void addToPlaylist(const QUrl& mrl, const QStringList &options = {});
+    Q_INVOKABLE void addToPlaylist(const QVariantList& itemIdList, const QStringList &options = {});
+
+    Q_INVOKABLE void addAndPlay(const MLItemId &itemId, const QStringList &options = {});
+    Q_INVOKABLE void addAndPlay(const QString& mrl, const QStringList &options = {});
+    Q_INVOKABLE void addAndPlay(const QUrl& mrl, const QStringList &options = {});
+    Q_INVOKABLE void addAndPlay(const QVariantList&itemIdList, const QStringList &options = {});
+    Q_INVOKABLE void insertIntoPlaylist(size_t index, const QVariantList &itemIds /*QList<MLParentId>*/, const QStringList &options = {});
 
     Q_INVOKABLE void reload();
 


=====================================
modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
=====================================
@@ -45,7 +45,7 @@ Widgets.NavigableFocusScope {
 
     function _actionAtIndex(index, model, selectionModel) {
         g_mainDisplay.showPlayer()
-        medialib.addAndPlay( model.getIdsForIndexes( selectionModel.selectedIndexes ) )
+        medialib.addAndPlay( model.getIdsForIndexes( selectionModel.selectedIndexes ), [":restore-playback-pos=2"] )
     }
 
     onFocusChanged: {
@@ -104,12 +104,7 @@ Widgets.NavigableFocusScope {
                 unselectedUnderlay: shadows.unselected
                 selectedUnderlay: shadows.selected
 
-                onItemDoubleClicked: {
-                    if ( model.id !== undefined ) {
-                        g_mainDisplay.showPlayer()
-                        medialib.addAndPlay( model.id )
-                    }
-                }
+                onItemDoubleClicked: recentVideoGridItem.play()
 
                 onItemClicked: {
                     recentVideoSelection.updateSelection( modifier , root.model.currentIndex, index )
@@ -128,6 +123,13 @@ Widgets.NavigableFocusScope {
                         duration: 100
                     }
                 }
+
+                function play() {
+                    if (model.id !== undefined) {
+                        g_mainDisplay.showPlayer()
+                        medialib.addAndPlay( model.id, [":restore-playback-pos=2"] )
+                    }
+                }
             }
 
             footer: Item {
@@ -137,7 +139,7 @@ Widgets.NavigableFocusScope {
             onSelectionUpdated: recentVideoSelection.updateSelection( keyModifiers, oldIndex, newIndex )
             onActionAtIndex: {
                 g_mainDisplay.showPlayer()
-                medialib.addAndPlay( model.getIdsForIndexes( recentVideoSelection.selectedIndexes ) )
+                medialib.addAndPlay( model.getIdsForIndexes( recentVideoSelection.selectedIndexes ), [":restore-playback-pos=2"] )
             }
 
             Widgets.GridShadows {


=====================================
modules/gui/qt/medialibrary/qml/VideoGridItem.qml
=====================================
@@ -34,6 +34,13 @@ Widgets.GridItem {
         model.channel || ""
     ].filter(function(a) { return a !== "" })
 
+    function play() {
+        if ( model.id !== undefined ) {
+            g_mainDisplay.showPlayer()
+            medialib.addAndPlay( model.id )
+        }
+    }
+
     image: model.thumbnail || VLCStyle.noArtCover
     title: model.title || i18n.qtr("Unknown title")
     subtitle: Helpers.msToString(model.duration) || ""
@@ -72,12 +79,7 @@ Widgets.GridItem {
         }
     }
 
-    onPlayClicked: {
-        if ( model.id !== undefined ) {
-            g_mainDisplay.showPlayer()
-            medialib.addAndPlay( model.id )
-        }
-    }
+    onPlayClicked: root.play()
     
     Behavior on newIndicatorMedian {
         NumberAnimation {


=====================================
modules/gui/qt/menus/qml_menu_wrapper.cpp
=====================================
@@ -377,8 +377,7 @@ void VideoContextMenu::popup(const QModelIndexList& selected, QPoint pos, QVaria
 
     action = m_menu->addAction( qtr("Play as audio") );
     connect(action, &QAction::triggered, [ml, itemIdList]( ) {
-        QStringList options({":no-video"});
-        ml->addAndPlay(itemIdList, &options);
+        ml->addAndPlay(itemIdList, {":no-video"});
     });
 
     if (options.contains("information") && options["information"].type() == QVariant::Int) {
@@ -543,8 +542,7 @@ void PlaylistMediaContextMenu::popup(const QModelIndexList & selected, QPoint po
     action = m_menu->addAction(qtr("Play as audio"));
 
     connect(action, &QAction::triggered, [ml, ids]() {
-        QStringList options({":no-video"});
-        ml->addAndPlay(ids, &options);
+        ml->addAndPlay(ids, {":no-video"});
     });
 
     if (options.contains("information") && options["information"].type() == QVariant::Int) {


=====================================
modules/gui/qt/playlist/media.hpp
=====================================
@@ -36,7 +36,7 @@ using InputItemPtr = vlc_shared_data_ptr_type(input_item_t,
 class Media
 {
 public:
-    Media(input_item_t *media = nullptr, const QStringList* options = nullptr)
+    Media(input_item_t *media = nullptr, const QStringList &options = {})
     {
         if (media)
         {
@@ -48,7 +48,7 @@ public:
         }
     }
 
-    Media(QString uri, QString name, const QStringList* options = nullptr)
+    Media(QString uri, QString name, const QStringList &options = {})
     {
         auto uUri = uri.toUtf8();
         auto uName = name.toUtf8();
@@ -60,23 +60,23 @@ public:
         setMediaOptions(options);
     }
 
-    void setMediaOptions(const QStringList* options = nullptr)
+    void setMediaOptions(const QStringList &options = {})
     {
-        if (options && options->count() > 0)
+        if (options.count() > 0)
         {
             char **ppsz_options = NULL;
             int i_options = 0;
 
-            ppsz_options = new char *[options->count()];
+            ppsz_options = new char *[options.count()];
             auto optionDeleter = vlc::wrap_carray<char*>(ppsz_options, [&i_options](char *ptr[]) {
                 for(int i = 0; i < i_options; i++)
                     free(ptr[i]);
                 delete[] ptr;
             });
 
-            for (int i = 0; i < options->count(); i++)
+            for (int i = 0; i < options.count(); i++)
             {
-                QString option = colon_unescape( options->at(i) );
+                QString option = colon_unescape( options[i] );
                 ppsz_options[i] = strdup(option.toUtf8().constData());
                 if (!ppsz_options[i])
                     throw std::bad_alloc();


=====================================
src/player/medialib.c
=====================================
@@ -36,8 +36,9 @@ vlc_player_input_RestoreMlStates(struct vlc_player_input* input, bool force_pos)
     if (force_pos)
         restore_pos = VLC_PLAYER_RESTORE_PLAYBACK_POS_ALWAYS;
     else
-        restore_pos = var_InheritInteger(player, "restore-playback-pos");
-    bool restore_states = var_InheritBool(player, "restore-playback-states");
+        restore_pos = var_InheritInteger(input->thread, "restore-playback-pos");
+
+    const bool restore_states = var_InheritBool(input->thread, "restore-playback-states");
 
     vlc_medialibrary_t* ml = vlc_ml_instance_get(input->player);
     if (!ml)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/74913342349c1a8d7f9a945b249af85644f148ea...304dcb438176ab0aff81ad4e5c7fb575d92ea643

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/74913342349c1a8d7f9a945b249af85644f148ea...304dcb438176ab0aff81ad4e5c7fb575d92ea643
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list