Deploy app desde ubuntu 20 a android 10
-
Hola. Estoy construyendo un teclado musical con nuevos instrumentos creados por mi usando pyqt.
Para hacer deploy app a android 10 estoy usando QtCreator. La aplicacion funciona bien pero lenta, 1 segundo de retrazo de la pulsacion a la emision del sonido, con QMediaPlayer cuando la uso con:void Teclado::reSound()
{
auto *player = new QMediaPlayer;
player->setMedia(QUrl("https://ia601403.us.archive.org/17/items/teclado1_20210818/Re.ogg"));
player->setVolume(100);
player->play();
}pero cunado pongo o similares:
void Teclado::doSound()
{
auto *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile("/data/user/0/downloads/teclados/teclado5/Do.wav"));
player->setVolume(100);
player->play();
}...no funciona. Creo que es porque no encuentra el sonido, es decir, el path es inadecuado o no encuentra en el path el sonido. Si alguien puede indicarme como hacer para se establezca la conexion con "/data/user/0/downloads/teclados/teclado5/Do.wav" o similar "/storage/emulated/0/downloads/teclados/teclado5/Do.wav" mediante el Deploy a android 10 . Es una cuestion de rapides, nadie quiere estar esperando.
Hacer Deploy con ubuntu 20 funciona bien dado que qtcreator funciona dentro de ubuntu 20 y el path con QUrl::fromLocalFile... funciona.
Este es el segundo programa que hago en qt5/c++.Tengo Nokia 1.3, Modelo TA-1207
Los archivos de trabajo son:
teclado.h
#pragma once #include <QWidget> #include <QApplication> #include <QPushButton> #include <QLabel> class Teclado : public QWidget { public: Teclado(QWidget *parent = nullptr); private slots: void doSound(); void dobSound(); void reSound(); void mibSound(); void miSound(); void faSound(); void fabSound(); void solSound(); void solbSound(); void laSound(); void siSound(); void sibSound(); void dosoSound(); private: QLabel *le1; };
main.cpp
#include <QApplication> #include "teclado.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Teclado window; window.setWindowTitle("Teclado - Electroma"); window.show(); return app.exec(); }
teclado.cpp
#include <QtGui>
#include <QGridLayout>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QApplication>
#include <QString>
#include <QDir>
#include <QtMultimedia/QMediaPlayer>
#include <QUrl>
#include <QObject>
#include "teclado.h"Teclado::Teclado(QWidget *parent)
: QWidget(parent) {auto *grid = new QGridLayout(this);
grid->setSpacing(2);QVector<QString> values({ "Do", "Re", "Mi", "Fa","", "Do#", "Mib", "Fa#", "Sol", "La", "Si","Do","", "Sol#", "Sib",""});
auto *btn0 = new QPushButton(values[0], this);
auto *btn1 = new QPushButton(values[1], this);
auto *btn2 = new QPushButton(values[2], this);
auto *btn3 = new QPushButton(values[3], this);
auto *btn5 = new QPushButton(values[5], this);
auto *btn6 = new QPushButton(values[6], this);
auto *btn7 = new QPushButton(values[7], this);
auto *btn8 = new QPushButton(values[8], this);
auto *btn9 = new QPushButton(values[9], this);
auto *btn10 = new QPushButton(values[10], this);
auto *btn11 = new QPushButton(values[11], this);auto *btn13 = new QPushButton(values[13], this);
auto *btn14 = new QPushButton(values[14], this);auto *le1 = new QLineEdit(this);
auto *teclado = new QLabel("Teclado:", this);
auto *blanco1 = new QLabel("", this);
auto *blanco2 = new QLabel("", this);
auto *blanco3 = new QLabel("", this);connect(btn0, &QPushButton::clicked, this, &Teclado::doSound);
btn0->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn0->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn1, &QPushButton::clicked, this, &Teclado::reSound);
btn1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn1->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn2, &QPushButton::clicked, this, &Teclado::miSound);
btn2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn2->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn3, &QPushButton::clicked, this, &Teclado::faSound);
btn3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn3->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");//espacio
blanco1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
blanco1->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn5, &QPushButton::clicked, this, &Teclado::dobSound);
btn5->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn5->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn6, &QPushButton::clicked, this, &Teclado::mibSound);
btn6->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn6->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn7, &QPushButton::clicked, this, &Teclado::fabSound);
btn7->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn7->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn8, &QPushButton::clicked, this, &Teclado::solSound);
btn8->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn8->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn9, &QPushButton::clicked, this, &Teclado::laSound);
btn9->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn9->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn10, &QPushButton::clicked, this, &Teclado::siSound);
btn10->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn10->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn11, &QPushButton::clicked, this, &Teclado::dosoSound);
btn11->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn11->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");//espacio
blanco2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
blanco2->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn13, &QPushButton::clicked, this, &Teclado::solbSound);
btn13->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn13->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");connect(btn14, &QPushButton::clicked, this, &Teclado::sibSound);
btn14->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn14->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");
//espacio
blanco3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
blanco3->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");le1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
le1->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");teclado->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
teclado->setStyleSheet("QPushButton {""font-family:DejaVu Math TeX Gyre;font-size: 45px;color: rgba(22, 22, 22, 90);" "background-color: rgba(0, 67, 255, 90)""}" "QPushButton:pressed {""color: lime;""background-color: rgba(0, 255, 255, 50)""}" "QPushButton:flat {""border: none; ""}");
grid->addWidget(btn0, 0, 0);
grid->addWidget(btn1, 0, 1);
grid->addWidget(btn2, 0, 2);
grid->addWidget(btn3, 0, 3);
grid->addWidget(blanco1, 1, 0);
grid->addWidget(btn5, 1, 1);
grid->addWidget(btn6, 1, 2);
grid->addWidget(btn7, 1, 3);
grid->addWidget(btn8, 2, 0);
grid->addWidget(btn9, 2, 1);
grid->addWidget(btn10, 2, 2);
grid->addWidget(btn11, 2, 3);
grid->addWidget(blanco2, 3, 0);
grid->addWidget(btn13, 3, 1);
grid->addWidget(btn14, 3, 2);
grid->addWidget(blanco3, 3, 3);
grid->addWidget(le1, 4, 3);
grid->addWidget(teclado, 4, 2);setLayout(grid);
}void Teclado::doSound()
{
auto *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile("/data/user/0/downloads/teclados/teclado5/Do.wav"));
player->setVolume(100);
player->play();
}void Teclado::reSound()
{
auto *player = new QMediaPlayer;
player->setMedia(QUrl("https://ia601403.us.archive.org/17/items/teclado1_20210818/Re.ogg"));
player->setVolume(100);
player->play();
}
.....