本文整理汇总了C++中phonon::MediaObject::play方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaObject::play方法的具体用法?C++ MediaObject::play怎么用?C++ MediaObject::play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phonon::MediaObject
的用法示例。
在下文中一共展示了MediaObject::play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playSoundStr
void AudioPlayer::playSoundStr(const QString &file) {
if (aboutToTerminate)
return;
for (std::vector<Phonon::MediaObject *>::iterator iter = soundVec.begin();
iter != soundVec.end(); ++iter) {
Phonon::MediaObject * prevSoundEffect = (*iter);
switch (prevSoundEffect->state()) {
case Phonon::StoppedState:
case Phonon::PausedState:
prevSoundEffect->clear();
prevSoundEffect->setCurrentSource(file);
prevSoundEffect->play();
return;
default:
break;
}
}
Phonon::MediaObject * soundEffect = Phonon::createPlayer(
Phonon::MusicCategory, file);
soundEffect->play();
soundVec.push_back(soundEffect);
printDebug(
"<font color=red><b>Notice: </b></font>AudioPlayer::playSoundStr: creating new MediaObject, current MediaObject count = "
+ QString::number(static_cast<unsigned>(soundVec.size())));
return;
}
示例2: togglePlayPause
void UBGraphicsAudioItemDelegate::togglePlayPause()
{
if ( mDelegated && mDelegated->mediaObject() )
{
Phonon::MediaObject* media = mDelegated->mediaObject();
if ( media->state() == Phonon::StoppedState ) {
media->play();
} else if ( media->state() == Phonon::PlayingState ) {
if ( media->remainingTime() <= 0 ) {
media->stop();
media->play();
} else {
media->pause();
if ( mDelegated->scene() )
mDelegated->scene()->setModified ( true );
}
} else if ( media->state() == Phonon::PausedState ) {
if ( media->remainingTime() <= 0 ) {
media->stop();
}
media->play();
} else if ( media->state() == Phonon::LoadingState ) {
mDelegated->mediaObject()->setCurrentSource(mDelegated->mediaFileUrl());
media->play();
} else if (media->state() == Phonon::ErrorState){
qDebug() << "Error appeared." << media->errorString();
}
}
}
示例3: main
int main(int argv, char **args)
{
QApplication app(argv, args);
app.setApplicationName("Audio effect tester");
Phonon::MediaObject *mediaObject = new Phonon::MediaObject;
mediaObject->setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"));
Phonon::AudioOutput *audioOutput =
new Phonon::AudioOutput(Phonon::MusicCategory);
//! [0]
QList<Phonon::EffectDescription> effectDescriptions =
Phonon::BackendCapabilities::availableAudioEffects();
Phonon::EffectDescription effectDescription = effectDescriptions.at(4);
Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);
//! [1]
Phonon::Effect *effect = new Phonon::Effect(effectDescription);
path.insertEffect(effect);
//! [0]
Phonon::EffectWidget *effectWidget = new Phonon::EffectWidget(effect);
effectWidget->show();
//! [1]
mediaObject->play();
effectWidget->setWindowTitle("Effect Name: " + effectDescription.name());
app.exec();
}
示例4: play
void PlayerManager::play(const FileHandle &file)
{
if(!m_setup)
setup();
if(!m_media[0] || !m_media[1] || !m_playlistInterface)
return;
stopCrossfade();
// The "currently playing" media object.
Phonon::MediaObject *mediaObject = m_media[m_curOutputPath];
if(file.isNull()) {
if(paused())
mediaObject->play();
else if(playing()) {
mediaObject->seek(0);
emit seeked(0);
}
else {
m_playlistInterface->playNext();
m_file = m_playlistInterface->currentFile();
if(!m_file.isNull())
{
mediaObject->setCurrentSource(KUrl::fromPath(m_file.absFilePath()));
mediaObject->play();
emit signalItemChanged(m_file);
}
}
}
else {
mediaObject->setCurrentSource(KUrl::fromPath(file.absFilePath()));
mediaObject->play();
if(m_file != file)
emit signalItemChanged(file);
m_file = file;
}
// Our state changed handler will perform the follow up actions necessary
// once we actually start playing.
}
示例5: playInstructions
void AudioOutputPrivate::playInstructions()
{
setupAudio();
if ( m_output ) {
m_output->enqueue( QUrl::fromLocalFile( m_voiceNavigation.instruction() ) );
m_output->play();
}
}
示例6: togglePlayPause
void UBGraphicsVideoItemDelegate::togglePlayPause()
{
if (delegated() && delegated()->mediaObject())
{
Phonon::MediaObject* media = delegated()->mediaObject();
if (media->state() == Phonon::StoppedState)
{
media->play();
}
else if (media->state() == Phonon::PlayingState)
{
if (media->remainingTime() <= 0)
{
media->stop();
media->play();
}
else
{
media->pause();
if(delegated()->scene())
delegated()->scene()->setModified(true);
}
}
else if (media->state() == Phonon::PausedState)
{
if (media->remainingTime() <= 0)
{
media->stop();
}
media->play();
}
else if ( media->state() == Phonon::LoadingState ){
delegated()->mediaObject()->setCurrentSource(delegated()->mediaFileUrl());
media->play();
}
else{
qDebug() << "Media state "<< media->state() << " not supported";
}
}
}
示例7: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug() << Phonon::BackendCapabilities::availableMimeTypes();
Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory,
Phonon::MediaSource("../myPhonon1/mysong.mp3"));
music->setParent(this);
music->play();
}
示例8: playSound
void SoundEditWidget::playSound()
{
if (!mHasSound) {
return;
}
Phonon::MediaObject *player = Phonon::createPlayer(Phonon::NotificationCategory);
QBuffer *soundData = new QBuffer(player);
soundData->setData(mSound);
player->setCurrentSource(soundData);
player->setParent(this);
connect(player, &Phonon::MediaObject::finished, player, &Phonon::MediaObject::deleteLater);
player->play();
}
示例9: playSound
/*#
void LayerSound::playSound(int frame) {
for(int i=0; i < sound.size(); i++) {
if (frame == framesPosition.at(i)) {
if (sound.at(i) != NULL && visible) sound[i]->play();
}
}
}
#*/
void LayerSound::playSound(int frame,int fps)
{
//QSettings settings("Pencil","Pencil");
//int fps = settings.value("fps").toInt();
for (int i = 0; i < sound.size(); ++i)
{
Phonon::MediaObject* media = sound.at(i);
if (media != NULL && visible)
{
int position = framesPosition.at(i);
if (frame < position)
{
media->stop();
}
else
{
Phonon::AudioOutput* audioOutput = NULL;
if (outputDevices.size() <= i)
{
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
outputDevices.push_back(audioOutput);
}
else
{
audioOutput = outputDevices.at(i);
}
int offsetInMs = floor((frame - position) * float(1000) / fps);
if (media->state() == Phonon::PlayingState)
{
if (fabs((float)media->currentTime() - offsetInMs) > 500.0f)
media->seek(offsetInMs);
}
else
{
if (frame > position)
{
media->pause();
media->seek(offsetInMs);
}
if (offsetInMs < soundSize[i])
{
Phonon::createPath(media, outputDevices.at(i));
media->play();
}
}
}
}
}
}
示例10: playSound
void SoundEditWidget::playSound()
{
if ( !mHasSound ) {
return;
}
#ifndef Q_OS_WINCE
Phonon::MediaObject* player = Phonon::createPlayer( Phonon::NotificationCategory );
QBuffer* soundData = new QBuffer( player );
soundData->setData( mSound );
player->setCurrentSource( soundData );
player->setParent( this );
connect( player, SIGNAL(finished()), player, SLOT(deleteLater()) );
player->play();
#endif
}
示例11: image
game::MainWindow::MainWindow(QWidget *parent) :
QWidget(parent),
m_width(1000),
m_height(800),
m_status(false),
m_frame_count(0),
m_i(0),
m_j(0),
m_next_cell(0),
m_clock_frame_count(0),
m_anim_end(false),
m_clock_start(false),
m_clock_x_cord(0),
m_animation_state(false)
{
QImage image(".\\res\\back_3.png");
m_game_width = image.width();
m_game_height = image.height();
setFixedSize(m_width, m_height);
m_click_coords.first = 0;
m_click_coords.second = 0;
setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
m_area_x0_coordinate = (this->width() - image.width())/2;
m_area_y0_coordinate = (this->height() - image.height())/2;
m_r = new game::graphic_engine::game_process(m_area_x0_coordinate, m_area_y0_coordinate, image.width()/*+30*/, image.height()/*+30*/, 57);
Phonon::MediaObject* mediaobject = new Phonon::MediaObject(this);
Phonon::AudioOutput *audio = new Phonon::AudioOutput(this);
assert(mediaobject != 0);
QString filename(".//res//music//Casino Ambiance Music.wav");
mediaobject->setCurrentSource(filename);
Phonon::createPath(mediaobject,audio);
mediaobject->play();
QPixmap pixmap(".\\res\\background.png");
QPalette palette;
palette.setBrush(/*this->backgroundRole()*/QPalette::Background, QBrush(pixmap));
this->setPalette(palette);
m_timer = new QTimer(this);
m_timer_clock = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(animate()));
connect(m_timer_clock, SIGNAL(timeout()), this, SLOT(animate_clock()));
m_timer->start(5);
m_timer_clock->start(60);
}
示例12: main
int main(int argv, char **args)
{
QApplication app(argv, args);
//![0]
Phonon::MediaObject *moo = new Phonon::MediaObject;;
Phonon::AudioOutput *device = new Phonon::AudioOutput;
Phonon::createPath(moo, device);
moo->setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"));
Phonon::SeekSlider *slider = new Phonon::SeekSlider;
slider->setMediaObject(moo);
slider->show();
moo->play();
//![0]
app.exec();
}
示例13: playClicked
void TrackAudioWidget::playClicked(int source_id)
{
std::cerr<<"TrackAudioWidget::playClicked with source_id : "<<source_id<<std::endl;
#ifdef _HAVE_PHONON_
Phonon::MediaObject *music =
Phonon::createPlayer(Phonon::MusicCategory,
Phonon::MediaSource(QString("log/source_") + QString::number(source_id) + QString(".wav")));
music->play();
#else
QProcess *process = new QProcess(this);
QString prog;
QStringList args;
#ifdef WIN32
prog = QString("sndrec32.exe");
args += QString("/play");
args += QString("/close");
args += QString("log/source_")+QString::number(source_id) + QString(".wav");
#endif
#ifdef linux
prog = QString("mplayer");
args += QString("log/source_")+QString::number(source_id) + QString(".wav");
#endif
#ifdef __APPLE_CC__
prog = QString("open");
args += QString("log/source_")+QString::number(source_id) + QString(".wav");
#endif
if (process)
{
process->start(prog,args);
}
#endif
}
示例14: main
int main(int argv, char **args)
{
QApplication app(argv, args);
app.setApplicationName("Volume slider tester");
Phonon::MediaObject *mediaObject = new Phonon::MediaObject;
mediaObject->setCurrentSource(QString("/home/gvatteka/Music/Lumme-Badloop.ogg"));
//! [0]
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
Phonon::createPath(mediaObject, audioOutput);
Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
volumeSlider->setAudioOutput(audioOutput);
//! [0]
mediaObject->play();
volumeSlider->show();
return app.exec();
}
示例15: main
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
app.setApplicationName("Flush");
QStringList args=app.arguments();
args.removeFirst();
QString appl=args.at(0);
args.removeFirst();
QProcess p;
p.setProcessChannelMode(QProcess::ForwardedChannels);
p.start(appl,args);
p.waitForFinished(-1);
Phonon::MediaObject *mediaObject = new Phonon::MediaObject();
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory);
Phonon::createPath(mediaObject, audioOutput);
if(p.exitCode()==0)
mediaObject->setCurrentSource(Phonon::MediaSource(":/flush.ogg"));
else
mediaObject->setCurrentSource(Phonon::MediaSource(":/sadtrombone.ogg"));
mediaObject->play();
QObject::connect(mediaObject,SIGNAL(finished()),&app,SLOT(quit()));
return app.exec();
}