remove vlc and replace by basic QMediaPlayer
This commit is contained in:
parent
a567428093
commit
fe7bbed7c1
10 changed files with 303 additions and 470 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ build-LenaPi-Desktop-Debug
|
|||
build-LenaPi-RasPi-Debug
|
||||
build-LenaPi-RasPi-Release
|
||||
LenaPi/LenaPi.pro.user.4.8-pre1
|
||||
musik
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
TEMPLATE = app
|
||||
|
||||
QT += qml quick
|
||||
QT += qml quick multimedia
|
||||
CONFIG += c++11
|
||||
LIBS += -lVLCQtCore -lVLCQtQml
|
||||
LIBS +=
|
||||
|
||||
SOURCES += main.cpp \
|
||||
controllers/MusicPlayer.cpp \
|
||||
models/NavigationListModel.cpp \
|
||||
models/NavigationItemModel.cpp \
|
||||
controllers/NavigationController.cpp \
|
||||
models/UiStateModel.cpp \
|
||||
controllers/MusicController.cpp \
|
||||
models/MusicModel.cpp \
|
||||
MouseEventSpy.cpp \
|
||||
EnergySaver.cpp \
|
||||
controllers/SettingsHandler.cpp
|
||||
|
|
@ -41,12 +40,12 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
HEADERS += \
|
||||
controllers/MusicPlayer.h \
|
||||
models/MusicPlayer.h \
|
||||
models/NavigationListModel.h \
|
||||
models/NavigationItemModel.h \
|
||||
controllers/NavigationController.h \
|
||||
models/UiStateModel.h \
|
||||
controllers/MusicController.h \
|
||||
models/MusicModel.h \
|
||||
MouseEventSpy.h \
|
||||
EnergySaver.h \
|
||||
controllers/SettingsHandler.h
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.8.2, 2021-09-26T21:51:47. -->
|
||||
<!-- Written by QtCreator 4.14.1, 2021-10-12T22:06:49. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{76cb87c9-a04b-479b-87ff-1b3ddab073a7}</value>
|
||||
<value type="QByteArray">{0510cc5f-8237-43aa-9f4f-ce9a2d4944ec}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
|
@ -49,209 +49,206 @@
|
|||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.Questionable</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">2</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{f9938f31-357c-4785-aa6e-21a3feac2ebf}</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{ebe72439-b95e-4a0f-b855-a910128856ec}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/araemer/source/LenaPi/build-LenaPi-Desktop-Debug</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/araemer/source/lenapi/build-LenaPi-Desktop-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/araemer/source/lenapi/build-LenaPi-Desktop-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
<value type="int" key="RunSystemFunction">0</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ar/source/LenaPi/build-LenaPi-Desktop-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/araemer/source/lenapi/build-LenaPi-Desktop-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/araemer/source/lenapi/build-LenaPi-Desktop-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="RunSystemFunction">0</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/ar/source/LenaPi/build-LenaPi-Desktop-Profile</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/araemer/source/lenapi/build-LenaPi-Desktop-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/araemer/source/lenapi/build-LenaPi-Desktop-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="RunSystemFunction">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||
<value type="QString">-e</value>
|
||||
<value type="QString">cpu-cycles</value>
|
||||
<value type="QString">--call-graph</value>
|
||||
<value type="QString">dwarf,4096</value>
|
||||
<value type="QString">-F</value>
|
||||
<value type="QString">250</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
|
|
@ -266,6 +263,7 @@
|
|||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
|
|
@ -291,22 +289,16 @@
|
|||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">LenaPi</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">LenaPi2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/ar/source/LenaPi/LenaPi/LenaPi.pro</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">LenaPi.pro</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/araemer/source/lenapi/LenaPi/LenaPi.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/araemer/source/lenapi/LenaPi/LenaPi.pro</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/araemer/source/LenaPi/build-LenaPi-Desktop-Debug</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
|
|
@ -317,10 +309,10 @@
|
|||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">20</value>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">20</value>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
#include "MusicController.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <models/MusicModel.h>
|
||||
#include <VLCQtCore/MediaPlayer.h>
|
||||
#include "EnergySaver.h"
|
||||
|
||||
MusicController::MusicController(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mVlc = new VlcInstance(VlcCommon::args(), this);
|
||||
mModel = new MusicModel(mVlc, this);
|
||||
mPlayer = new VlcMediaListPlayer(mVlc);
|
||||
mVlcAudio = new VlcAudio(mPlayer->mediaPlayer());
|
||||
|
||||
connect(mModel, &MusicModel::navigateTo, this, &MusicController::onNavigationRequest);
|
||||
|
||||
//connect(mModel, &MusicModel::play, mPlayer, &VlcMediaListPlayer::play);
|
||||
connect(mModel, &MusicModel::play, [this](){
|
||||
mVlcAudio->setVolume(mModel->getAudioVolume());
|
||||
mPlayer->play();
|
||||
});
|
||||
connect(mModel, &MusicModel::stop, mPlayer, &VlcMediaListPlayer::stop);
|
||||
connect(mModel, &MusicModel::previous, mPlayer, &VlcMediaListPlayer::previous);
|
||||
connect(mModel, &MusicModel::next, mPlayer, &VlcMediaListPlayer::next);
|
||||
connect(mModel, &MusicModel::pause, mPlayer->mediaPlayer(), &VlcMediaPlayer::pause);
|
||||
connect(mModel, &MusicModel::audioVolumeChanged, mVlcAudio, &VlcAudio::setVolume);
|
||||
|
||||
connect(mPlayer, SIGNAL(nextItemSet(VlcMedia*)), mModel, SLOT(onNextMediaSet(VlcMedia*)));
|
||||
connect(mPlayer->mediaPlayer(), &VlcMediaPlayer::lengthChanged, mModel, &MusicModel::onLengthChanged);
|
||||
connect(mPlayer->mediaPlayer(), &VlcMediaPlayer::timeChanged, mModel, &MusicModel::onTimeChanged);
|
||||
|
||||
// hand over player signals to energy saver in order to determine player activity.
|
||||
connect(mPlayer->mediaPlayer(), &VlcMediaPlayer::timeChanged, EnergySaver::instance(), &EnergySaver::restartTimer);
|
||||
}
|
||||
|
||||
MusicController::~MusicController()
|
||||
{
|
||||
mPlayer->deleteLater();
|
||||
mVlcAudio->deleteLater();
|
||||
}
|
||||
|
||||
void MusicController::initPlayer(NavigationItemModel *item)
|
||||
{
|
||||
if(item != mModel->getCurrentItem()){
|
||||
mPlayer->stop();
|
||||
mModel->init(item);
|
||||
}
|
||||
if(!mIsMediaListSet){
|
||||
mPlayer->setMediaList(mModel->getMedia());
|
||||
mIsMediaListSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MusicController::setContext(QQmlContext *context)
|
||||
{
|
||||
mContext = context;
|
||||
setContextProperties();
|
||||
}
|
||||
|
||||
void MusicController::setContextProperties()
|
||||
{
|
||||
if(!mContext) return;
|
||||
mContext->setContextProperty("musicModel", mModel);
|
||||
}
|
||||
|
||||
void MusicController::onNavigationRequest(NavigationItemModel *item)
|
||||
{
|
||||
if(mModel->isPlaying()) {
|
||||
mModel->playPause();
|
||||
}
|
||||
emit navigateTo(item);
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef MUSICCONTROLLER_H
|
||||
#define MUSICCONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlContext>
|
||||
#include <models/NavigationItemModel.h>
|
||||
|
||||
#include <VLCQtCore/Common.h>
|
||||
#include <VLCQtCore/Instance.h>
|
||||
#include <VLCQtCore/MediaListPlayer.h>
|
||||
#include <VLCQtCore/Audio.h>
|
||||
|
||||
class MusicModel;
|
||||
|
||||
class MusicController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void navigateTo(NavigationItemModel* item);
|
||||
|
||||
public:
|
||||
MusicController(QObject *parent = Q_NULLPTR);
|
||||
~MusicController();
|
||||
|
||||
void initPlayer(NavigationItemModel* item);
|
||||
|
||||
void setContext(QQmlContext* context);
|
||||
|
||||
private:
|
||||
void setContextProperties();
|
||||
|
||||
QQmlContext* mContext = Q_NULLPTR;
|
||||
|
||||
MusicModel* mModel = Q_NULLPTR;
|
||||
|
||||
VlcInstance* mVlc = Q_NULLPTR;
|
||||
VlcMediaListPlayer* mPlayer = Q_NULLPTR;
|
||||
VlcAudio* mVlcAudio = Q_NULLPTR;
|
||||
|
||||
bool mIsMediaListSet = false;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Stop player if necessary and forward signal navigatTo
|
||||
* @param item target of navigation request
|
||||
* @see navigateTo(NavigationItemModel* item);
|
||||
*/
|
||||
void onNavigationRequest(NavigationItemModel* item);
|
||||
};
|
||||
|
||||
#endif // MUSICCONTROLLER_H
|
||||
194
LenaPi/controllers/MusicPlayer.cpp
Normal file
194
LenaPi/controllers/MusicPlayer.cpp
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
#include "MusicPlayer.h"
|
||||
#include <QDir>
|
||||
#include <QMediaPlaylist>
|
||||
|
||||
|
||||
|
||||
MusicPlayer::MusicPlayer(QObject *parent) : QMediaPlayer(parent)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
MusicPlayer::~MusicPlayer()
|
||||
{
|
||||
}
|
||||
|
||||
void MusicPlayer::init(NavigationItemModel *item)
|
||||
{
|
||||
if(mCurrentItem == item){
|
||||
return;
|
||||
}
|
||||
mCurrentItem = item;
|
||||
emit currentItemChanged();
|
||||
|
||||
reset();
|
||||
clearMediaList();
|
||||
|
||||
readMedia(mCurrentItem->getPath());
|
||||
}
|
||||
|
||||
void MusicPlayer::navigateBack()
|
||||
{
|
||||
emit navigateTo(mCurrentItem);
|
||||
}
|
||||
|
||||
void MusicPlayer::playPause()
|
||||
{
|
||||
mIsPlaying = !mIsPlaying;
|
||||
emit isPlayingChanged();
|
||||
if(mIsPlaying)
|
||||
play();
|
||||
else
|
||||
pause();
|
||||
}
|
||||
|
||||
void MusicPlayer::stopMusic()
|
||||
{
|
||||
if(mIsPlaying){
|
||||
mIsPlaying = false;
|
||||
emit isPlayingChanged();
|
||||
|
||||
reset();
|
||||
|
||||
emit stop();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::playNext()
|
||||
{
|
||||
//emit next();
|
||||
if(!mIsPlaying){
|
||||
mIsPlaying = true;
|
||||
emit isPlayingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::playPrevious()
|
||||
{
|
||||
//emit previous();
|
||||
if(!mIsPlaying){
|
||||
mIsPlaying = true;
|
||||
emit isPlayingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
NavigationItemModel *MusicPlayer::getCurrentItem()
|
||||
{
|
||||
return mCurrentItem;
|
||||
}
|
||||
|
||||
bool MusicPlayer::isPlaying() const
|
||||
{
|
||||
return mIsPlaying;
|
||||
}
|
||||
|
||||
bool MusicPlayer::hasNext() const
|
||||
{
|
||||
return mHasNext;
|
||||
}
|
||||
|
||||
bool MusicPlayer::hasPrevious() const
|
||||
{
|
||||
return mHasPrevious;
|
||||
}
|
||||
|
||||
void MusicPlayer::setAudioVolume(int newVolume)
|
||||
{
|
||||
if(newVolume != mAudioVolume){
|
||||
if(newVolume > 100){
|
||||
mAudioVolume = 100;
|
||||
} else if(newVolume < 0){
|
||||
mAudioVolume = 0;
|
||||
} else {
|
||||
mAudioVolume = newVolume;
|
||||
}
|
||||
emit audioVolumeChanged(mAudioVolume);
|
||||
}
|
||||
}
|
||||
|
||||
double MusicPlayer::getProgress() const
|
||||
{
|
||||
return mCurrentMediaItemProgress;
|
||||
}
|
||||
|
||||
QString MusicPlayer::getMediaTitle() const
|
||||
{
|
||||
return mMediaTitle;
|
||||
}
|
||||
|
||||
QString MusicPlayer::getMediaLength()
|
||||
{
|
||||
return timeToString(mCurrentMediaItemLength);
|
||||
}
|
||||
|
||||
QString MusicPlayer::getTime()
|
||||
{
|
||||
return timeToString(mCurrentTime);
|
||||
}
|
||||
|
||||
void MusicPlayer::onTimeChanged(int time)
|
||||
{
|
||||
mCurrentMediaItemProgress = (double) time / mCurrentMediaItemLength;
|
||||
mCurrentTime = time;
|
||||
emit progressChanged();
|
||||
}
|
||||
|
||||
void MusicPlayer::onLengthChanged(int length)
|
||||
{
|
||||
mCurrentMediaItemLength= length;
|
||||
emit mediaLengthChanged();
|
||||
}
|
||||
|
||||
void MusicPlayer::reset()
|
||||
{
|
||||
mHasNext = false;
|
||||
mHasPrevious = false;
|
||||
emit hasNextChanged();
|
||||
emit hasPreviousChanged();
|
||||
|
||||
mCurrentMediaItemProgress = 0.0;
|
||||
mCurrentTime = 0.0;
|
||||
emit progressChanged();
|
||||
|
||||
mCurrentMediaItemLength = 0.0;
|
||||
emit mediaLengthChanged();
|
||||
}
|
||||
|
||||
void MusicPlayer::clearMediaList()
|
||||
{
|
||||
if(playlist()){
|
||||
playlist()->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::readMedia(const QString& path)
|
||||
{
|
||||
auto dir = QDir(path);
|
||||
if(!dir.exists()) return;
|
||||
|
||||
// create playlist if necessary
|
||||
auto playList = playlist();
|
||||
if(!playList){
|
||||
playList = new QMediaPlaylist(this);
|
||||
setPlaylist(playList);
|
||||
}
|
||||
|
||||
// add audio files to playlist
|
||||
dir.setNameFilters({"*.mp3", "*.flac"});
|
||||
auto files = dir.entryInfoList(QDir::Files);
|
||||
for(auto file:files){
|
||||
auto fileName = file.absoluteFilePath();
|
||||
auto fileUrl = QUrl::fromLocalFile(fileName);
|
||||
qDebug() << fileName << fileUrl;
|
||||
playList->addMedia(QMediaContent(fileUrl));
|
||||
}
|
||||
}
|
||||
|
||||
QString MusicPlayer::timeToString(int time)
|
||||
{
|
||||
int sec = time/1000;
|
||||
int min = sec/60;
|
||||
sec = sec-min*60;
|
||||
QString secStr = (sec < 10) ? "0"+QString::number(sec) : QString::number(sec);
|
||||
return QString::number(min) + ":" + secStr;
|
||||
}
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef MUSICMODEL_H
|
||||
#define MUSICMODEL_H
|
||||
#ifndef MUSICPLAYER_H
|
||||
#define MUSICPLAYER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QMediaPlayer>
|
||||
#include <models/NavigationItemModel.h>
|
||||
#include <VLCQtCore/MediaList.h>
|
||||
|
||||
class MusicModel : public QObject
|
||||
class MusicPlayer : public QMediaPlayer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -23,11 +22,6 @@ class MusicModel : public QObject
|
|||
signals:
|
||||
void navigateTo(NavigationItemModel *item);
|
||||
void currentItemChanged();
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
void previous();
|
||||
void next();
|
||||
void hasPreviousChanged();
|
||||
void hasNextChanged();
|
||||
void isPlayingChanged();
|
||||
|
|
@ -37,20 +31,13 @@ signals:
|
|||
void audioVolumeChanged(int newVolume);
|
||||
|
||||
public:
|
||||
MusicModel(VlcInstance* instance, QObject *parent = Q_NULLPTR);
|
||||
~MusicModel();
|
||||
MusicPlayer(QObject *parent = Q_NULLPTR);
|
||||
~MusicPlayer();
|
||||
|
||||
void init(NavigationItemModel* item);
|
||||
|
||||
Q_INVOKABLE void navigateBack();
|
||||
Q_INVOKABLE void playPause();
|
||||
Q_INVOKABLE void stopMusic();
|
||||
Q_INVOKABLE void playNext();
|
||||
Q_INVOKABLE void playPrevious();
|
||||
|
||||
NavigationItemModel *getCurrentItem();
|
||||
|
||||
VlcMediaList *getMedia();
|
||||
|
||||
bool isPlaying() const;
|
||||
bool hasNext() const;
|
||||
|
|
@ -72,7 +59,12 @@ public:
|
|||
QString getTime();
|
||||
|
||||
public slots:
|
||||
void onNextMediaSet(VlcMedia* media);
|
||||
void navigateBack();
|
||||
void playPause();
|
||||
void stopMusic();
|
||||
void playNext();
|
||||
void playPrevious();
|
||||
|
||||
void onTimeChanged(int time);
|
||||
void onLengthChanged(int length);
|
||||
|
||||
|
|
@ -80,7 +72,6 @@ private:
|
|||
void reset();
|
||||
void clearMediaList();
|
||||
void readMedia(const QString& path);
|
||||
void setMediaTitle(VlcMedia* media);
|
||||
QString timeToString(int time);
|
||||
|
||||
|
||||
|
|
@ -92,9 +83,7 @@ private:
|
|||
double mCurrentMediaItemProgress = 0;
|
||||
int mAudioVolume{50};
|
||||
QString mMediaTitle = QString("");
|
||||
NavigationItemModel* mCurrentItem = Q_NULLPTR;
|
||||
VlcMediaList* mMedia = Q_NULLPTR;
|
||||
VlcInstance* mVlc = Q_NULLPTR;
|
||||
NavigationItemModel* mCurrentItem = nullptr;
|
||||
};
|
||||
|
||||
#endif // MUSICMODEL_H
|
||||
#endif // MUSICPLAYER_H
|
||||
|
|
@ -6,15 +6,15 @@
|
|||
#include <models/NavigationItemModel.h>
|
||||
#include <models/NavigationListModel.h>
|
||||
#include <models/UiStateModel.h>
|
||||
#include <controllers/MusicController.h>
|
||||
#include <controllers/MusicPlayer.h>
|
||||
|
||||
NavigationController::NavigationController(QObject *parent) : QObject(parent),
|
||||
mRootItem(new NavigationItemModel(this)),
|
||||
mNavList(new NavigationListModel(this)),
|
||||
mUiState(new UiStateModel(this)),
|
||||
mMusicController(new MusicController(this))
|
||||
mMediaPlayer(new MusicPlayer(this))
|
||||
{
|
||||
connect(mMusicController, &MusicController::navigateTo, [this](NavigationItemModel* item) {
|
||||
connect(mMediaPlayer, &MusicPlayer::navigateTo, [this](NavigationItemModel* item) {
|
||||
mUiState->showNavigation();
|
||||
mNavList->navigateTo(item);
|
||||
});
|
||||
|
|
@ -40,7 +40,6 @@ void NavigationController::setContext(QQmlContext *context)
|
|||
{
|
||||
mContext = context;
|
||||
setContextProperties();
|
||||
mMusicController->setContext(mContext);
|
||||
}
|
||||
|
||||
void NavigationController::setContextProperties()
|
||||
|
|
@ -48,6 +47,7 @@ void NavigationController::setContextProperties()
|
|||
if(!mContext) return;
|
||||
mContext->setContextProperty("navigationList", mNavList);
|
||||
mContext->setContextProperty("uiStateModel", mUiState);
|
||||
mContext->setContextProperty("musicModel", mMediaPlayer);
|
||||
}
|
||||
|
||||
void NavigationController::add(const QString &path, NavigationItemModel *parentItem)
|
||||
|
|
@ -99,7 +99,7 @@ void NavigationController::onNavigationRequest()
|
|||
if(item->hasChildren())
|
||||
mNavList->setModelItems(item->getChildren());
|
||||
else {
|
||||
mMusicController->initPlayer(item);
|
||||
mMediaPlayer->init(item);
|
||||
mUiState->showMusicPlayer();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
class NavigationItemModel;
|
||||
class NavigationListModel;
|
||||
class UiStateModel;
|
||||
class MusicController;
|
||||
class MusicPlayer;
|
||||
|
||||
/**
|
||||
* @brief Main controller controlling ui state, navigation and music player.
|
||||
|
|
@ -59,7 +59,7 @@ private:
|
|||
NavigationListModel* mNavList;
|
||||
|
||||
UiStateModel* mUiState;
|
||||
MusicController* mMusicController;
|
||||
MusicPlayer* mMediaPlayer;
|
||||
|
||||
QString mRootPath = ".";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,218 +0,0 @@
|
|||
#include "MusicModel.h"
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <VLCQtCore/Media.h>
|
||||
|
||||
MusicModel::MusicModel(VlcInstance* instance, QObject *parent) : QObject(parent),
|
||||
mVlc(instance), mMedia(new VlcMediaList(instance))
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
MusicModel::~MusicModel()
|
||||
{
|
||||
// do not delete! will cause segmentation fault
|
||||
//if(mMedia)
|
||||
// mMedia->deleteLater();
|
||||
}
|
||||
|
||||
void MusicModel::init(NavigationItemModel *item)
|
||||
{
|
||||
if(mCurrentItem == item){
|
||||
return;
|
||||
}
|
||||
mCurrentItem = item;
|
||||
emit currentItemChanged();
|
||||
|
||||
reset();
|
||||
clearMediaList();
|
||||
|
||||
readMedia(mCurrentItem->getPath());
|
||||
|
||||
setMediaTitle(mMedia->at(0));
|
||||
}
|
||||
|
||||
void MusicModel::navigateBack()
|
||||
{
|
||||
emit navigateTo(mCurrentItem);
|
||||
}
|
||||
|
||||
void MusicModel::playPause()
|
||||
{
|
||||
mIsPlaying = !mIsPlaying;
|
||||
emit isPlayingChanged();
|
||||
if(mIsPlaying)
|
||||
emit play();
|
||||
else
|
||||
emit pause();
|
||||
}
|
||||
|
||||
void MusicModel::stopMusic()
|
||||
{
|
||||
if(mIsPlaying){
|
||||
mIsPlaying = false;
|
||||
emit isPlayingChanged();
|
||||
|
||||
reset();
|
||||
|
||||
emit stop();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicModel::playNext()
|
||||
{
|
||||
emit next();
|
||||
if(!mIsPlaying){
|
||||
mIsPlaying = true;
|
||||
emit isPlayingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicModel::playPrevious()
|
||||
{
|
||||
emit previous();
|
||||
if(!mIsPlaying){
|
||||
mIsPlaying = true;
|
||||
emit isPlayingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
NavigationItemModel *MusicModel::getCurrentItem()
|
||||
{
|
||||
return mCurrentItem;
|
||||
}
|
||||
|
||||
VlcMediaList *MusicModel::getMedia()
|
||||
{
|
||||
return mMedia;
|
||||
}
|
||||
|
||||
bool MusicModel::isPlaying() const
|
||||
{
|
||||
return mIsPlaying;
|
||||
}
|
||||
|
||||
bool MusicModel::hasNext() const
|
||||
{
|
||||
return mHasNext;
|
||||
}
|
||||
|
||||
bool MusicModel::hasPrevious() const
|
||||
{
|
||||
return mHasPrevious;
|
||||
}
|
||||
|
||||
void MusicModel::setAudioVolume(int newVolume)
|
||||
{
|
||||
if(newVolume != mAudioVolume){
|
||||
if(newVolume > 100){
|
||||
mAudioVolume = 100;
|
||||
} else if(newVolume < 0){
|
||||
mAudioVolume = 0;
|
||||
} else {
|
||||
mAudioVolume = newVolume;
|
||||
}
|
||||
emit audioVolumeChanged(mAudioVolume);
|
||||
}
|
||||
}
|
||||
|
||||
double MusicModel::getProgress() const
|
||||
{
|
||||
return mCurrentMediaItemProgress;
|
||||
}
|
||||
|
||||
QString MusicModel::getMediaTitle() const
|
||||
{
|
||||
return mMediaTitle;
|
||||
}
|
||||
|
||||
QString MusicModel::getMediaLength()
|
||||
{
|
||||
return timeToString(mCurrentMediaItemLength);
|
||||
}
|
||||
|
||||
QString MusicModel::getTime()
|
||||
{
|
||||
return timeToString(mCurrentTime);
|
||||
}
|
||||
|
||||
void MusicModel::onNextMediaSet(VlcMedia *media)
|
||||
{
|
||||
setMediaTitle(media);
|
||||
|
||||
mHasNext = true;
|
||||
mHasPrevious = true;
|
||||
if(mMedia->at(0) == media){
|
||||
mHasPrevious = false;
|
||||
}
|
||||
if(mMedia->at(mMedia->count()-1) == media){
|
||||
mHasNext = false;
|
||||
}
|
||||
emit hasPreviousChanged();
|
||||
emit hasNextChanged();
|
||||
}
|
||||
|
||||
void MusicModel::onTimeChanged(int time)
|
||||
{
|
||||
mCurrentMediaItemProgress = (double) time / mCurrentMediaItemLength;
|
||||
mCurrentTime = time;
|
||||
emit progressChanged();
|
||||
}
|
||||
|
||||
void MusicModel::onLengthChanged(int length)
|
||||
{
|
||||
mCurrentMediaItemLength= length;
|
||||
emit mediaLengthChanged();
|
||||
}
|
||||
|
||||
void MusicModel::reset()
|
||||
{
|
||||
mHasNext = false;
|
||||
mHasPrevious = false;
|
||||
emit hasNextChanged();
|
||||
emit hasPreviousChanged();
|
||||
|
||||
mCurrentMediaItemProgress = 0.0;
|
||||
mCurrentTime = 0.0;
|
||||
emit progressChanged();
|
||||
|
||||
mCurrentMediaItemLength = 0.0;
|
||||
emit mediaLengthChanged();
|
||||
}
|
||||
|
||||
void MusicModel::clearMediaList()
|
||||
{
|
||||
while(mMedia->count() > 0){
|
||||
mMedia->removeMedia(0);
|
||||
}
|
||||
}
|
||||
|
||||
void MusicModel::readMedia(const QString& path)
|
||||
{
|
||||
auto dir = QDir(path);
|
||||
if(!dir.exists()) return;
|
||||
|
||||
auto fileNames = dir.entryList(QDir::Files);
|
||||
for(auto file:fileNames){
|
||||
if(file.endsWith(".flac") || file.endsWith(".mp3")){
|
||||
mMedia->addMedia(new VlcMedia(dir.filePath(file), true, mVlc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString MusicModel::timeToString(int time)
|
||||
{
|
||||
int sec = time/1000;
|
||||
int min = sec/60;
|
||||
sec = sec-min*60;
|
||||
QString secStr = (sec < 10) ? "0"+QString::number(sec) : QString::number(sec);
|
||||
return QString::number(min) + ":" + secStr;
|
||||
}
|
||||
|
||||
void MusicModel::setMediaTitle(VlcMedia *media)
|
||||
{
|
||||
auto list = media->currentLocation().split("/");
|
||||
auto title = list.at(list.count() -1 );
|
||||
mMediaTitle = title.left(title.lastIndexOf("."));
|
||||
emit mediaTitleChanged();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue