Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Last active January 24, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmarr58/0328e4fea3973fbfdf0cb0242f29804d to your computer and use it in GitHub Desktop.
Save esmarr58/0328e4fea3973fbfdf0cb0242f29804d to your computer and use it in GitHub Desktop.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<stdlib.h>
#include<QMediaPlayer>
#include <QFileInfo>
#include <QFileDialog>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
reproductor = new QMediaPlayer(this);
connect(ui->botonPlay, &QPushButton::clicked, reproductor, &QMediaPlayer::play);
connect(ui->botonPausa, &QPushButton::clicked, reproductor, &QMediaPlayer::pause);
connect(ui->botonStop, &QPushButton::clicked, reproductor, &QMediaPlayer::stop);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString nombreArchivo = QFileDialog::getOpenFileName(this,"Selecciona un archivo",".mp3");
reproductor->setMedia(QUrl::fromLocalFile(nombreArchivo));
}
void MainWindow::on_verticalSlider_sliderMoved(int position)
{
reproductor->setVolume(position);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment