[vlmc-devel] MediaLibrary: Expose an audio media model

Hugo Beauzée-Luyssen git at videolan.org
Fri Jul 8 22:56:47 CEST 2016


vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Jul  8 16:44:49 2016 +0200| [8fd95a66c4248d2b3a6262bc5c7e4fb2730a66b9] | committer: Hugo Beauzée-Luyssen

MediaLibrary: Expose an audio media model

> https://code.videolan.org/videolan/vlmc/commit/8fd95a66c4248d2b3a6262bc5c7e4fb2730a66b9
---

 src/Library/MediaLibrary.cpp | 17 +++++++++++++++--
 src/Library/MediaLibrary.h   |  1 +
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/Library/MediaLibrary.cpp b/src/Library/MediaLibrary.cpp
index 5f49ae7..43f313e 100644
--- a/src/Library/MediaLibrary.cpp
+++ b/src/Library/MediaLibrary.cpp
@@ -44,7 +44,7 @@ MediaLibraryModel* MediaLibrary::model( MediaLibrary::MediaType type ) const
         case MediaType::Video:
             return m_videoModel;
         case MediaType::Audio:
-            return nullptr;
+            return m_audioModel;
     }
     Q_UNREACHABLE();
 }
@@ -76,6 +76,7 @@ MediaLibrary::workspaceChanged( const QVariant& workspace )
         //FIXME: Race condition, this could trigger onMediaAdded before m_videoModel has been created.
         //However, we need the model to be created AFTER the ML gets initialized
         m_videoModel = new MediaLibraryModel( *m_ml, medialibrary::IMedia::Type::VideoType, this );
+        m_audioModel = new MediaLibraryModel( *m_ml, medialibrary::IMedia::Type::AudioType, this );
         m_initialized = true;
     }
     //else FIXME, and relocate the media library
@@ -84,7 +85,19 @@ MediaLibrary::workspaceChanged( const QVariant& workspace )
 void MediaLibrary::onMediaAdded( std::vector<medialibrary::MediaPtr> mediaList )
 {
     for ( auto m : mediaList )
-        m_videoModel->addMedia( m );
+    {
+        switch ( m->type() )
+        {
+        case medialibrary::IMedia::Type::VideoType:
+            m_videoModel->addMedia( m );
+            break;
+        case medialibrary::IMedia::Type::AudioType:
+            m_audioModel->addMedia( m );
+            break;
+        default:
+            Q_UNREACHABLE();
+        }
+    }
 }
 
 void MediaLibrary::onMediaUpdated( std::vector<medialibrary::MediaPtr> )
diff --git a/src/Library/MediaLibrary.h b/src/Library/MediaLibrary.h
index 5baf4df..ddec833 100644
--- a/src/Library/MediaLibrary.h
+++ b/src/Library/MediaLibrary.h
@@ -80,6 +80,7 @@ private:
 private:
     std::unique_ptr<medialibrary::IMediaLibrary> m_ml;
     MediaLibraryModel* m_videoModel;
+    MediaLibraryModel* m_audioModel;
     bool m_initialized;
 };
 



More information about the Vlmc-devel mailing list