当前位置: 首页>>代码示例>>C++>>正文


C++ QMediaPlayer::play方法代码示例

本文整理汇总了C++中QMediaPlayer::play方法的典型用法代码示例。如果您正苦于以下问题:C++ QMediaPlayer::play方法的具体用法?C++ QMediaPlayer::play怎么用?C++ QMediaPlayer::play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMediaPlayer的用法示例。


在下文中一共展示了QMediaPlayer::play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: timeIsOut

void MainWindow::timeIsOut()
{
	if(ui->checkBox->isChecked()&&++currentSegIndex<segTime.count()){
		timer->stop();
		ui->listWidget->setCurrentRow(currentSegIndex);
		on_start_clicked();
		ui->label_4->setText(QString::number(currentSegIndex+1));
	}
	else if(ui->checkBox_2->isChecked()&&++currentSegIndex<segTime.count()){
		timer->stop();
		if(fnames.count()>0)
			player.play();
		ui->start->setText(QString::fromLocal8Bit("開始"));
		ui->listWidget->setCurrentRow(currentSegIndex);
	}
	else{
		timer->stop();
		if(fnames.count()>0)
			player.play();
		if(ui->listWidget->currentRow()>=0){
			ui->spinBox->setEnabled(true);
			ui->spinBox_2->setEnabled(true);
			ui->spinBox_3->setEnabled(true);
		}
		ui->checkBox->setEnabled(true);
		ui->start->setText(QString::fromLocal8Bit("開始"));
		currentSegSec=0;
		currentSegIndex=-1;
	}
}
开发者ID:B10215037,项目名称:timer,代码行数:30,代码来源:mainwindow.cpp

示例2: playSegment

void WaveformView::playSegment(LipsyncPhrase *fPhrase, LipsyncWord *fWord, LipsyncPhoneme *fPhoneme, int32 fScrubFrame)
{
    bool playSegment = false;
    QMediaPlayer *audioPlayer = fDoc->GetAudioPlayer();
    int32 startFrame;
    fAudioStopFrame = -1;
    if (audioPlayer)
    {
        if (fPhrase)
        {
            playSegment = true;
            startFrame = fPhrase->fStartFrame;
            fAudioStopFrame = fPhrase->fEndFrame + 1;
        }
        else if (fWord)
        {
            playSegment = true;
            startFrame = fWord->fStartFrame;
            fAudioStopFrame = fWord->fEndFrame + 1;
        }
        else if (fPhoneme)
        {
            playSegment = true;
            startFrame = fPhoneme->fFrame;
            fAudioStopFrame = startFrame + 1;
        }
        if (playSegment)
        {
            float f = ((real)startFrame / (real)fDoc->Fps()) * 1000.0f;
            audioPlayer->setPosition(PG_ROUND(f));
            audioPlayer->play();
            emit(frameChanged(fScrubFrame));
        }
    }
}
开发者ID:muddcliff,项目名称:Papagayo,代码行数:35,代码来源:waveformview.cpp

示例3: deleteTank

void Tank::deleteTank()
{
    alive = false;
    head->setPixmap(QPixmap(":/images/images/empty.png").scaled(pixsize,pixsize));
    setPixmap(QPixmap(":/images/images/empty.png").scaled(pixsize,pixsize));

    int stime;
    long ltime;
    int random;
    ltime = time(NULL);
    stime = (unsigned) ltime/2;
    srand(stime);
    random = rand()%3 +1;

    QMediaPlayer *explode = new QMediaPlayer();
    explode->setMedia(QUrl("qrc:/sounds/sounds/tank/explode" + QString::number(random) + ".mp3"));
    explode->play();

    // анимация
    gif_anim = new QLabel();
    gif_anim->setStyleSheet("background-color: transparent;");
    QMovie *movie = new QMovie(":/images/images/anim/Explo.gif");
    gif_anim->setMovie(movie);
    gif_anim->move(x()-25,y()-25);
    movie->setScaledSize(QSize(250,250));
    movie->start();
    QGraphicsProxyWidget *proxy = game->scene->addWidget(gif_anim);
    QTimer::singleShot(2500, this, SLOT(deleteGif()));
}
开发者ID:Lonsofore,项目名称:TankBattles,代码行数:29,代码来源:tank.cpp

示例4: main

int main(int argc, char *argv[])
{
	QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
	QApplication a(argc, argv);

	const QString fileAbsPath = a.arguments().at(1);
	qDebug("Opening %s...", qPrintable(fileAbsPath));

	QMediaPlayer p;
	p.setMedia(QMediaContent(QUrl(fileAbsPath)));

	QGraphicsVideoItem* item = new QGraphicsVideoItem;
	QGraphicsScene* scene = new QGraphicsScene;
	scene->addText("TEST");
	p.setVideoOutput(item);
	scene->addItem(item);
	scene->addRect(0, 0, 100, 100, QPen(Qt::red), QBrush(Qt::red));
	item->setPos(0, 0);

	//QImage image(1920, 1080, QImage::Format_ARGB32);
	//image.fill(Qt::blue);

	//QPainter painter(&image);
	//painter.setRenderHint(QPainter::Antialiasing);
	//scene->render(&painter);

	QGraphicsView view(scene);
	//view.scene()->addItem(item);
	view.setViewport(new QOpenGLWidget);
	view.show();

	p.play();

	return a.exec();
}
开发者ID:carlonluca,项目名称:pi,代码行数:35,代码来源:main.cpp

示例5: play

void Audio::play(const QString &filename, const bool doubleVolume)
{
    if (SoundCache == nullptr)
        return;
    QMediaPlayer *sound = nullptr;
    if (!SoundCache->contains(filename))
    {
        sound = new QMediaPlayer;
        sound->setMedia(QUrl(filename));
        SoundCache->insert(filename, sound);
    }
    else
    {
        sound = SoundCache->object(filename);
        if (sound->state() == QMediaPlayer::PlayingState)
        {
            return;
        }
    }

    if (sound == nullptr)
        return;

    sound->setVolume((doubleVolume ? 2 : 1) * Config.EffectVolume * 100);
    sound->play();
}
开发者ID:SwordElucidator,项目名称:QSanguosha-For-Saimoe,代码行数:26,代码来源:audio.cpp

示例6: main

int             main(int argc, char *argv[])
{
    QApplication    a(argc, argv);
    QVideoWidget    *videoOutputWidget = new QVideoWidget();
    QMediaPlayer    *player = new QMediaPlayer();
    QVideoProbe     *probe = new QVideoProbe();
    DemoCoq*        demo = new DemoCoq();
    QTimer*         timer = new QTimer();

    probe->setSource(player);
    player->setMedia(QUrl::fromLocalFile("C:/Users/louis/Desktop/Cinefeel/Video.avi"));

    player->setVideoOutput(videoOutputWidget);

    videoOutputWidget->show();

    player->play();

    demo->connect(timer, SIGNAL(timeout()), SLOT(updateColor()));
    timer->start(1000 / 10);
    demo->addAPIConnector(new APIConnector("192.168.43.254:34000"));
//    demo->addAPIConnector(new APIConnector("192.168.43.254:34000"));
//    demo->addAPIConnector(new APIConnector("192.168.43.254:34000"));
//    demo->addAPIConnector(new APIConnector("192.168.43.254:34000"));
    //demo.launch();

    VideoDebugger   *videoDebugger = new VideoDebugger((QObject *)0, true);
    QObject::connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), videoDebugger, SLOT(mediaCheck(QMediaPlayer::MediaStatus)));
    QObject::connect(probe, SIGNAL(videoFrameProbed(QVideoFrame)), videoDebugger, SLOT(processFrame(QVideoFrame)));
    return a.exec();
}
开发者ID:skanight,项目名称:Cinefeel,代码行数:31,代码来源:main.cpp

示例7: playSound

void playSound(QString path) {
    QMediaPlayer *player = new QMediaPlayer;
    player->setMedia(QUrl(path));
    player->play();

    QObject::connect(player, &QMediaPlayer::stateChanged, &QMediaPlayer::deleteLater);
}
开发者ID:johnwchadwick,项目名称:pengsh,代码行数:7,代码来源:main.cpp

示例8: beep

/**
 * Nofication.beep - http://docs.phonegap.com/phonegap_notification_notification.md.html#notification.beep
 */
void Notification::beep( int scId, int ecId, int p_times ) {
    Q_UNUSED(scId)
    Q_UNUSED(ecId)
    Q_UNUSED(p_times)
    QMediaPlayer* player = new QMediaPlayer;
    player->setVolume(100);
    player->setMedia(QUrl::fromLocalFile("/usr/share/sounds/ui-tones/snd_default_beep.wav"));
    player->play();
}
开发者ID:ljo,项目名称:incubator-cordova-qt,代码行数:12,代码来源:notification.cpp

示例9: on_pushButton_clicked

void MainWindow::on_pushButton_clicked()
{
    player.stop();
    float number;
    std::istringstream iss(std_str);
    iss >> number ;

    int num = number *1000;
    player.setMedia(QUrl::fromLocalFile(QFileInfo(file_main).absoluteFilePath()));
    player.setVolume(100);
    player.play();

    delay(num+2);
    qDebug() << num << endl;
    player2.setMedia(QUrl::fromLocalFile(QFileInfo(file_ref).absoluteFilePath()));
    player2.setVolume(100);
    player2.play();
}
开发者ID:biruk-belay,项目名称:Multimedia_Synch,代码行数:18,代码来源:mainwindow.cpp

示例10: getVoice

void Form::getVoice()
{
    QMediaPlayer* player = new QMediaPlayer();

    QUrl url(m_word.voice_url);

    player->setMedia(url);
    player->setVolume(100);
    player->play();

    m_reply = m_net_manager.get(QNetworkRequest(url));
    connect(m_reply,SIGNAL(finished()),this,SLOT(downloadFinished()));
}
开发者ID:hellogdut,项目名称:Translator,代码行数:13,代码来源:form.cpp

示例11: main

int main(int argc, char *argv[])
{
    QMediaPlayer player;

    QVideoWidget videoWidget;
    player->setVideoOutput(videoWidget);

    videoWidget->show();
    player.setMedia(QUrl::fromLocalFile());
    player->play();

    return a.exec();
}
开发者ID:amapig,项目名称:QtPractice,代码行数:13,代码来源:main.cpp

示例12: QGraphicsScene

Game::Game(QWidget *parent){
    // create the scene
    scene = new QGraphicsScene();
    scene->setSceneRect(0,0,1000,800); // make the scene 800x600 instead of infinity by infinity (default)

    setBackgroundBrush(QBrush(QImage(":/images/bg.jpg")));

    // make the newly created scene the scene to visualize (since Game is a QGraphicsView Widget,
    // it can be used to visualize scenes)
    setScene(scene);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFixedSize(1000,800);

    // create the player
    player = new MyRect();
    //player->setRect(0,0,100,100); // change the rect from 0x0 (default) to 100x100 pixels
    player->setPos(400,500); // TODO generalize to always be in the middle bottom of screen
    // make the player focusable and set it to be the current focus
    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();
    // add the player to the scene
    scene->addItem(player);

    // create the score/health
    score = new Score();
    scene->addItem(score);
    health = new Health();
    health->setPos(health->x(),health->y()+25);
    scene->addItem(health);

    // spawn enemies
    QTimer * timer = new QTimer();
    QObject::connect(timer,SIGNAL(timeout()),player,SLOT(spawn()));
    timer->start(2000);



    // play background music
    QMediaPlayer * music = new QMediaPlayer();
    music->setMedia(QUrl("qrc:/sounds/Counter-strike_1.6-Zak_Belica_(glavnaya_tema_-_fonovaya_muzyka_v_nachale_igry).mp3"));
    music->play();



    show();
}
开发者ID:Tarazali,项目名称:C-Game,代码行数:47,代码来源:Game.cpp

示例13: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPixmap startPixmap(":/new/icon/icon/flower.gif");
    startPixmap.size();
    QSplashScreen splash(startPixmap);
    splash.show();
    for(long i=0; i<100000000;i++);
    MainWindow w;
    w.show();
    splash.finish(&w);
    QMediaPlayer *player = new QMediaPlayer;
    player->setMedia(QUrl::fromUserInput("qrc:/new/sound/1.wav"));
    player->setVolume(50);
    player->play();
    return a.exec();
}
开发者ID:Fahy15,项目名称:MyNotepad,代码行数:17,代码来源:main.cpp

示例14: QGraphicsScene

Game::Game(QWidget *parent)
{
    QRect rec = QApplication::desktop()->screenGeometry();
    int height = rec.height();
    int width = rec.width();

    QGraphicsScene *scene = new QGraphicsScene();
    scene->setSceneRect(0,0,width,height);

    QGraphicsView *view = new QGraphicsView(scene);

    scene->setBackgroundBrush(QImage("://img/bg.png"));

    //player
    ship *player=new ship();
    scene->addItem(player);
    player->setPos(width/2, height-70);

    //scoring
    score = new Score();
    scene->addItem(score);

    //life
    life = new Life();
    life->setPos(life->x(),life->y()+25);
    scene->addItem(life);

    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();

    //enemies
    QTimer*timer=new QTimer();
    QObject::connect(timer,SIGNAL(timeout()),player,SLOT(spawn()));
    timer->start(2000);

    //music
    QMediaPlayer * music = new QMediaPlayer();
    music->setMedia(QUrl("qrc:/sounds/bgmusic.mp3"));
    music->play();

    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->showFullScreen();
}
开发者ID:swapnil-pandey,项目名称:RetroShoot,代码行数:44,代码来源:game.cpp

示例15: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QMediaPlayer player;

    PSMoveRotationReaderThread thread(&player);

    QString filename = QDir().absoluteFilePath(INPUT_FILENAME);
    QUrl url = QUrl::fromLocalFile(filename);
    player.setMedia(QMediaContent(url));

    /* Start with a really slow playback rate */
    player.setPlaybackRate(.01);
    player.play();

    thread.start();

    return app.exec();
}
开发者ID:0x53A,项目名称:psmoveapi,代码行数:19,代码来源:playbackspeed.cpp


注:本文中的QMediaPlayer::play方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。