• 大小: 515KB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: 其他
  • 标签: linux  Qt  mplayer  ubuntu  

资源简介

在网上已有源码基础上修改为ubuntu下可用 源程序在windows下运行正常

资源截图

代码片段和文件信息

#include 
#include “implayer.h“
#include “ui_implayer.h“
#include 
#include
#include



IMplayer::IMplayer(QWidget *parent) :
    QMainWindow(parent)
    ui(new Ui::IMplayer)
{
    isMute = 0;
    isPlay = 1;
    isLength = 1;
    timePos = 0;
    timeLength = 0;

    ui->setupUi(this);
    ui->scheduleSlider->setRange(0999);
    ui->voiceSlider->setRange(0 99);

    mplayerProcess = new QProcess(this);
    mplayerProcess->setProcessChannelMode(QProcess::MergedChannels);
    //mplayerProgram = tr(“D:/workstation/IMplayer/mplayer/mplayer.exe“);
    mplayerProgram = tr(“/usr/bin/mplayer“);
    timeClock = new QTimer(this);

    connect(mplayerProcess SIGNAL(readyReadStandardOutput()) this SLOT(back_Message_slot()));
    connect(timeClock SIGNAL(timeout()) this SLOT(back_posMessage_slot()));

}

IMplayer::~IMplayer()
{
    delete ui;
}

void IMplayer::setUI()
{

}

void IMplayer::play(QString fileName)
{
    mplayerProcess->close();

    ui->posTimeLineEdit->setText(“00:00:00“);
    ui->lengthTimeLineEdit->setText(“00:00:00“);
    ui->scheduleSlider->setValue(0);
    ui->voiceSlider->setValue(99);
    ui->playPushButton->setEnabled(1);
    ui->pausePushButton->setEnabled(1);
    ui->stopPushButton->setEnabled(1);
    ui->stepPushButton->setEnabled(1);
    ui->backPushButton->setEnabled(1);
    ui->scheduleSlider->setEnabled(1);
    ui->voiceSlider->setEnabled(1);
    ui->quietPushButton->setEnabled(1);

    QStringList args;
    args << tr(“-slave“);
    args << “-quiet“;

#ifdef Q_WS_WIN

    args << tr(“-wid“) << QString::number((unsigned int)(ui->widgetview->winId()));
    args << “-zoom“;
    args << “-vo“ << “directx:noaccel“;
#else
    args << tr(“-wid“) << QString::number((unsigned int)(ui->widgetview->winId()));
    args << “-zoom“;
#endif

    args << fileName;

    timePos = 0;
    //ui->posTimeLineEdit->setText(“00:00:00“);
    timeLength = 1;
    isLength = 1;

    mplayerProcess->start(mplayerProgram args);

    mplayerProcess->write(“get_time_length\n“);
}

void IMplayer::on_playPushButton_clicked()
{

    if(isPlay == 0)
    {
        mplayerProcess->write(“pause\n“);
        isPlay = 1;
        timeClock->start();
    }
}

void IMplayer::on_pausePushButton_clicked()
{
    if(isPlay == 1)
    {
        mplayerProcess->write(“pause\n“);
        //timeClock->isActive()= false;
        isPlay = 0;
        timeClock->stop();

    }
}

void IMplayer::on_stopPushButton_clicked()
{
    timeClock->stop();
    mplayerProcess->write(“pausing_keep stop\n“);

    ui->posTimeLineEdit->setText(“00:00:00“);
    ui->lengthTimeLineEdit->setText(“00:00:00“);
    ui->scheduleSlider->setValue(0);
    ui->voiceSlider->setValue(99);
    ui->playPushButton->setDisabled(1);
    ui->pausePushButton->setDisabled(1);
    ui->stopPushButton->setDisabled(1);
    ui->stepPushButton->setDisabled(1);
 

评论

共有 条评论