diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a79d0b..6f9ade8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(qyouradio VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt6 REQUIRED COMPONENTS Quick) +find_package(Qt6 REQUIRED COMPONENTS Quick Multimedia) qt_standard_project_setup(REQUIRES 6.8) @@ -12,11 +12,21 @@ qt_add_executable(appqyouradio main.cpp ) +qt_add_resources(appqyouradio "resources" + PREFIX "/" + FILES + resources/logo.png +) + +set_source_files_properties(Player.qml + PROPERTIES QT_QML_SINGLETON_TYPE TRUE) + qt_add_qml_module(appqyouradio URI qyouradio VERSION 1.0 QML_FILES Main.qml + Player.qml ViewPlayer.qml ViewSettings.qml ) @@ -33,7 +43,7 @@ set_target_properties(appqyouradio PROPERTIES ) target_link_libraries(appqyouradio - PRIVATE Qt6::Quick + PRIVATE Qt6::Quick Qt6::Multimedia ) include(GNUInstallDirs) diff --git a/Main.qml b/Main.qml index c63e9e0..aca2be5 100755 --- a/Main.qml +++ b/Main.qml @@ -8,7 +8,7 @@ import QYRComponents 1.0 ApplicationWindow { width: 1280 height: 800 - title: qsTr("Hello World") + title: qsTr("QYouRadio") ColumnLayout { anchors.fill: parent @@ -21,12 +21,12 @@ ApplicationWindow { TabButton { text: qsTr("Autoradio") } - TabButton { - text: qsTr("Live Mix") - } - TabButton { - text: qsTr("Deep Bass") - } + // TabButton { + // text: qsTr("Live Mix") + // } + // TabButton { + // text: qsTr("Deep Bass") + // } TabButton { text: qsTr("Settings") } @@ -40,15 +40,24 @@ ApplicationWindow { currentIndex: tabbar.currentIndex ViewPlayer { title: qsTr("Autoradio") + streamURL: "https://youradio.nonamesoft.xyz/api/autoradio" } - ViewPlayer { - title: qsTr("Live Radio") - } - ViewPlayer { - title: qsTr("Deep Bass") - } + // ViewPlayer { + // title: qsTr("Live Radio") + // streamURL: "https://youradio.nonamesoft.xyz/api/live" + // } + // ViewPlayer { + // title: qsTr("Deep Bass") + // streamURL: "https://youradio.nonamesoft.xyz/api/deepbass" + // } ViewSettings { } } + + YouAds { + Layout.fillWidth: false + Layout.alignment: Qt.AlignHCenter + visible: tabbar.currentIndex != 1 + } } } diff --git a/Player.qml b/Player.qml new file mode 100644 index 0000000..5180d87 --- /dev/null +++ b/Player.qml @@ -0,0 +1,30 @@ +import QtMultimedia 6.8 + +pragma Singleton + +MediaPlayer { + source: "" + + function startPlaying(url) { + if (player.playing) { + return; + } + console.log("Starting playback from " + url); + player.source = url; + player.play(); + } + + function stopPlaying() { + console.log("Stopping playback..."); + player.source = ""; + player.stop(); + } + + audioOutput: AudioOutput { + volume: 0.4 + } + + onErrorOccurred: function(error, errorString) { + player.stopPlaying(); + } +} diff --git a/ViewPlayer.qml b/ViewPlayer.qml index 33a41a7..e94ba9a 100644 --- a/ViewPlayer.qml +++ b/ViewPlayer.qml @@ -63,7 +63,15 @@ ColumnLayout { Button { Layout.rightMargin: 5 - text: "Play" + text: Player.loading ? "Loading" : (Player.playing ? "Pause" : "Play") + + onClicked: function() { + if (Player.playing) { + Player.stopPlaying(); + } else { + Player.startPlaying(parent.parent.streamURL); + } + } } Slider { @@ -78,9 +86,4 @@ ColumnLayout { Item { Layout.fillHeight: true } - - YouAds { - Layout.fillWidth: false - Layout.alignment: Qt.AlignHCenter - } } \ No newline at end of file diff --git a/ViewSettings.qml b/ViewSettings.qml index ac04420..1d2d5b7 100644 --- a/ViewSettings.qml +++ b/ViewSettings.qml @@ -41,8 +41,17 @@ RowLayout { } } + Rectangle { + Layout.fillHeight: true + width: 5 + color: Colors.text + radius: 5 + } + StackLayout { Layout.fillWidth: true Layout.fillHeight: true + currentIndex: settingsCategory.currentIndex + } } \ No newline at end of file diff --git a/main.cpp b/main.cpp index 5557f37..b4fd983 100755 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -12,5 +13,7 @@ int main(int argc, char *argv[]) Qt::QueuedConnection); engine.loadFromModule("qyouradio", "Main"); + app.setWindowIcon(QIcon(":/resources/logo.png")); + return app.exec(); } diff --git a/resources/logo.ico b/resources/logo.ico new file mode 100644 index 0000000..a5e8af9 Binary files /dev/null and b/resources/logo.ico differ diff --git a/resources/logo.png b/resources/logo.png new file mode 100644 index 0000000..4205905 Binary files /dev/null and b/resources/logo.png differ