Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

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
20 changes: 20 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);

return app.exec();
}
167 changes: 167 additions & 0 deletions main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import QtQuick 2.0
import QtQuick.Window 2.15
import QtMultimedia 5.15
import QtQuick.Controls 2.12
import QtQuick.Dialogs 1.3


Window {
id:root
visible: true
width: 640
height: 480
title: qsTr("Hello World")

property int selectedIndex: -1


MediaPlayer {
id: player;
volume: volumeSlider.volume
source: url
playlist: Playlist{
id:playlist
}
}

ListView {
id:listview
width:parent.width/2
height: parent.height
anchors.left: parent.left
anchors.bottom: parent.bottom
model: playlist;
spacing: 5
delegate: Rectangle{
width: listview.width
border.color: (model.index == root.selectedIndex) ? "red" : "gray"
height: 25
Text {
id: songUrl
text: source
visible: true
}
Text {
id: songname
text: sou
}
MouseArea{
id:delegatemousearea
anchors.fill:parent
onClicked: {
root.selectedIndex = model.index
}
onDoubleClicked: {
playlist.moveItem(root.selectedIndex,0)
playlist.previous()
player.play()
}
}
}
}

Label{
id:label
anchors.bottom: progresstime.top
anchors.left: add.right
text: player.metaData.title + " " + player.metaData.albumArtist
}
Image {
id: songImage
height: parent.height-next.height-add.height-label.height-progresstime.height
width: parent.width-listview.width
anchors.bottom: label.top
anchors.right: pause.right
source: (player.metaData.posterUrl!=="undefind")?"qrc:/png-transparent-color-drawing-headphones-illustration-musical-note-game-photography-stage.png":player.metaData.posterUrl
}
FileDialog{
id:add_File
nameFilters: ["Song files(*.mp3)"]
onAccepted: {
playlist.addItem(fileUrl);
}
}

Button{
id:add
text: "add"
anchors.bottom: privious.top
anchors.right: privious.right
anchors.bottomMargin: 5
onClicked: {
add_File.open()
}
}
Button{
id:privious
text:"privious"
anchors.right: play.left
anchors.bottom: parent.bottom
anchors.rightMargin: 5
onClicked: {
playlist.previous();
}
}

Button{
id:next
text: "next"
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 5
onClicked: {
playlist.next();
}
}
Button{
id:play
text: "play"
anchors.right: pause.left
anchors.rightMargin: 5
anchors.bottom: parent.bottom
onClicked: {
player.play();
}
}
Button{
id:pause
text: "pause"
anchors.right: next.left
anchors.rightMargin: 5
anchors.bottom: parent.bottom
onClicked: {
player.pause();
}
}
Slider {
id: volumeSlider
anchors.left: add.right
anchors.bottom: add.bottom
anchors.leftMargin: 5
property real volume: QtMultimedia.convertVolume(volumeSlider.value,
QtMultimedia.LogarithmicVolumeScale,
QtMultimedia.LinearVolumeScale)
}
Slider{
id:progresstime
anchors.bottom: volumeSlider.top
anchors.left: add.left
anchors.right: next.right
from: 0
to: player.duration
stepSize: 1000

onPressedChanged: {
if (!pressed && player.seekable)
player.seek(progresstime.value)
}
Connections{
target: player
onPositionChanged:{
progresstime.value=player.position
}
}

}
}

7 changes: 7 additions & 0 deletions qml.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>C:/Users/Alexander/Pictures/персонаж.png</file>
<file>png-transparent-color-drawing-headphones-illustration-musical-note-game-photography-stage.png</file>
</qresource>
</RCC>