本文整理汇总了C++中phonon::MediaObject::errorString方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaObject::errorString方法的具体用法?C++ MediaObject::errorString怎么用?C++ MediaObject::errorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phonon::MediaObject
的用法示例。
在下文中一共展示了MediaObject::errorString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
}
示例2: slotStateChanged
void PlayerManager::slotStateChanged(Phonon::State newstate, Phonon::State oldstate)
{
// Use sender() since either media object may have sent the signal.
Phonon::MediaObject *mediaObject = qobject_cast<Phonon::MediaObject *>(sender());
if(!mediaObject)
return;
// Handle errors for either media object
if(newstate == Phonon::ErrorState) {
QString errorMessage =
i18nc(
"%1 will be the /path/to/file, %2 will be some string from Phonon describing the error",
"JuK is unable to play the audio file<nl/><filename>%1</filename><nl/>"
"for the following reason:<nl/><message>%2</message>",
m_file.absFilePath(),
mediaObject->errorString()
);
switch(mediaObject->errorType()) {
case Phonon::NoError:
kDebug() << "received a state change to ErrorState but errorType is NoError!?";
break;
case Phonon::NormalError:
forward();
KMessageBox::information(0, errorMessage);
break;
case Phonon::FatalError:
stop();
KMessageBox::sorry(0, errorMessage);
break;
}
}
// Now bail out if we're not dealing with the currently playing media
// object.
if(mediaObject != m_media[m_curOutputPath])
return;
// Handle state changes for the playing media object.
if(newstate == Phonon::StoppedState && oldstate != Phonon::LoadingState) {
// If this occurs it should be due to a transitory shift (i.e. playing a different
// song when one is playing now), since it didn't occur in the error handler. Just
// in case we really did abruptly stop, handle that case in a couple of seconds.
QTimer::singleShot(2000, this, SLOT(slotUpdateGuiIfStopped()));
JuK::JuKInstance()->setWindowTitle(i18n("JuK"));
emit signalStop();
}
else if(newstate == Phonon::PausedState) {
emit signalPause();
}
else { // PlayingState or BufferingState
action("pause")->setEnabled(true);
action("stop")->setEnabled(true);
action("forward")->setEnabled(true);
if(action<KToggleAction>("albumRandomPlay")->isChecked())
action("forwardAlbum")->setEnabled(true);
action("back")->setEnabled(true);
JuK::JuKInstance()->setWindowTitle(i18nc(
"%1 is the artist and %2 is the title of the currently playing track.",
"%1 - %2 :: JuK",
m_file.tag()->artist(),
m_file.tag()->title()));
emit signalPlay();
}
}