本文整理汇总了C++中MediaSource::fileName方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaSource::fileName方法的具体用法?C++ MediaSource::fileName怎么用?C++ MediaSource::fileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaSource
的用法示例。
在下文中一共展示了MediaSource::fileName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSource
/*
* !reimp
*/
void MediaObject::setSource(const MediaSource &source)
{
QMultiMap<QString, QString> ret;
ret.insert(QLatin1String("ARTIST"), "Nokia Dude");
ret.insert(QLatin1String("ALBUM"), "Sound of silence");
ret.insert(QLatin1String("DATE"), "2009");
m_error = Phonon::NoError;
setState(Phonon::LoadingState);
m_source = source;
currentPos = 0;
if((source.fileName().contains(".avi")) ||
(source.fileName().contains(".mp4"))) {
m_hasVideo = true;
emit hasVideoChanged(m_hasVideo);
}
if(source.fileName().contains(".wav")) {
QFile file(source.fileName());
if (file.open(QIODevice::ReadOnly)) {
int len = file.read((char*)&header, sizeof(CombinedHeader));
if(len == sizeof(CombinedHeader)) {
if(memcmp(&header.riff.descriptor.id, riffId, 4) != 0) {
// Not a valid wav file, to satisfy unit test for mediaobject
m_error = Phonon::FatalError;
//m_state = Phonon::ErrorState;
m_errorString = "Invalid wav file";
setState(Phonon::ErrorState);
file.close();
return;
}
}
file.close();
}
}
emit metaDataChanged(ret);
emit currentSourceChanged(source);
emit totalTimeChanged(m_totalTime);
setState(Phonon::StoppedState);
}
示例2: append
/** Add a track to this Playlist instance. */
void Playlist::append(const MediaSource &m)
{
// Resolve metaDatas from TagLib
TagLib::FileRef f(m.fileName().toLocal8Bit().data());
if (!f.isNull()) {
sources.append(m);
QString title(f.tag()->title().toCString());
if (title.isEmpty()) {
// Filename in a MediaSource doesn't handle cross-platform QDir::separator(), so '/' is hardcoded
title = m.fileName().split('/').last();
}
// Then, construct a new row with correct informations
QList<QTableWidgetItem *> widgetItems;
QTableWidgetItem *trackItem = new QTableWidgetItem(QString::number(f.tag()->track()));
QTableWidgetItem *titleItem = new QTableWidgetItem(title);
QTableWidgetItem *albumItem = new QTableWidgetItem(f.tag()->album().toCString());
QTableWidgetItem *lengthItem = new QTableWidgetItem(this->convertTrackLength(f.audioProperties()->length()));
QTableWidgetItem *artistItem = new QTableWidgetItem(f.tag()->artist().toCString());
QTableWidgetItem *ratingItem = new QTableWidgetItem("***");
QTableWidgetItem *yearItem = new QTableWidgetItem(QString::number(f.tag()->year()));
widgetItems << trackItem << titleItem << albumItem << lengthItem << artistItem << ratingItem << yearItem;
int currentRow = rowCount();
insertRow(currentRow);
QFont font = Settings::getInstance()->font(Settings::PLAYLIST);
for (int i=0; i < widgetItems.length(); i++) {
QTableWidgetItem *item = widgetItems.at(i);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setFont(font);
setItem(currentRow, i, item);
QFontMetrics fm(font);
setRowHeight(currentRow, fm.height());
}
trackItem->setTextAlignment(Qt::AlignCenter);
lengthItem->setTextAlignment(Qt::AlignCenter);
ratingItem->setTextAlignment(Qt::AlignCenter);
yearItem->setTextAlignment(Qt::AlignCenter);
}
}
示例3: testIODevice
void MediaSourceTest::testIODevice()
{
const QByteArray data("0192380");
QBuffer *buffer = new QBuffer;
buffer->setData(data);
buffer->open(QIODevice::ReadOnly);
MediaSource a(buffer);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QVERIFY(a.stream() != 0);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QVERIFY(b.stream() != 0);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QVERIFY(c.stream() != 0);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
delete buffer;
QCOMPARE(a.type(), MediaSource::Invalid);
QCOMPARE(b.type(), MediaSource::Invalid);
QCOMPARE(c.type(), MediaSource::Invalid);
const AbstractMediaStream *null = 0;
QCOMPARE(a.stream(), null);
QCOMPARE(b.stream(), null);
QCOMPARE(c.stream(), null);
}
示例4: testStream
void MediaSourceTest::testStream()
{
AbstractMediaStream *stream = new Stream;
MediaSource a(stream);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
delete stream;
QCOMPARE(a.type(), MediaSource::Invalid);
QCOMPARE(b.type(), MediaSource::Invalid);
QCOMPARE(c.type(), MediaSource::Invalid);
const AbstractMediaStream *null = 0;
QCOMPARE(a.stream(), null);
QCOMPARE(b.stream(), null);
QCOMPARE(c.stream(), null);
}
示例5: testDiscType
void MediaSourceTest::testDiscType()
{
for (int i = 0; i <= Phonon::Vcd; ++i) {
Phonon::DiscType discType = static_cast<Phonon::DiscType>(i);
AbstractMediaStream *stream = 0;
MediaSource a(discType);
QCOMPARE(a.type(), MediaSource::Disc);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), discType);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Disc);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), discType);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Disc);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), discType);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
}
}
示例6: testUrl
void MediaSourceTest::testUrl()
{
QUrl url("http://www.example.com/music.ogg");
AbstractMediaStream *stream = 0;
MediaSource a(url);
QCOMPARE(a.type(), MediaSource::Url);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), url);
QCOMPARE(a.discType(), Phonon::NoDisc);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Url);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), url);
QCOMPARE(b.discType(), Phonon::NoDisc);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Url);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), url);
QCOMPARE(c.discType(), Phonon::NoDisc);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
}
示例7: testQtResource
void MediaSourceTest::testQtResource()
{
const QString filename(":/ogg/zero.ogg");
MediaSource a(filename);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QVERIFY(a.stream() != 0);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QVERIFY(b.stream() != 0);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QVERIFY(c.stream() != 0);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
}
示例8: url
void MMF::MediaObject::createPlayer(const MediaSource &source)
{
TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi);
TRACE_ENTRY("state %d source.type %d", state(), source.type());
TRACE_ENTRY("source.type %d", source.type());
MediaType mediaType = MediaTypeUnknown;
AbstractPlayer* oldPlayer = m_player.data();
const bool oldPlayerHasVideo = oldPlayer->hasVideo();
const bool oldPlayerSeekable = oldPlayer->isSeekable();
QString errorMessage;
// Determine media type
switch (source.type()) {
case MediaSource::LocalFile:
mediaType = fileMediaType(source.fileName());
break;
case MediaSource::Url:
{
const QUrl url(source.url());
if (url.scheme() == QLatin1String("file")) {
mediaType = fileMediaType(url.toLocalFile());
}
else {
// Streaming playback is generally not supported by the implementation
// of the audio player API, so we use CVideoPlayerUtility for both
// audio and video streaming.
mediaType = MediaTypeVideo;
}
}
break;
case MediaSource::Invalid:
case MediaSource::Disc:
case MediaSource::Stream:
errorMessage = tr("Error opening source: type not supported");
break;
case MediaSource::Empty:
TRACE_0("Empty media source");
break;
}
if (oldPlayer)
oldPlayer->close();
AbstractPlayer* newPlayer = 0;
// Construct newPlayer using oldPlayer (if not 0) in order to copy
// parameters (volume, prefinishMark, transitionTime) which may have
// been set on oldPlayer.
switch (mediaType) {
case MediaTypeUnknown:
TRACE_0("Media type could not be determined");
newPlayer = new DummyPlayer(oldPlayer);
errorMessage = tr("Error opening source: media type could not be determined");
break;
case MediaTypeAudio:
newPlayer = new AudioPlayer(this, oldPlayer);
break;
case MediaTypeVideo:
#ifdef PHONON_MMF_VIDEO_SURFACES
newPlayer = SurfaceVideoPlayer::create(this, oldPlayer);
#else
newPlayer = DsaVideoPlayer::create(this, oldPlayer);
#endif
break;
}
if (oldPlayer)
emit abstractPlayerChanged(0);
m_player.reset(newPlayer);
emit abstractPlayerChanged(newPlayer);
if (oldPlayerHasVideo != hasVideo()) {
emit hasVideoChanged(hasVideo());
}
if (oldPlayerSeekable != isSeekable()) {
emit seekableChanged(isSeekable());
}
connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64)));
connect(m_player.data(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), SIGNAL(stateChanged(Phonon::State,Phonon::State)));
connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished()));
connect(m_player.data(), SIGNAL(bufferStatus(int)), SIGNAL(bufferStatus(int)));
connect(m_player.data(), SIGNAL(metaDataChanged(QMultiMap<QString,QString>)), SIGNAL(metaDataChanged(QMultiMap<QString,QString>)));
connect(m_player.data(), SIGNAL(aboutToFinish()), SIGNAL(aboutToFinish()));
connect(m_player.data(), SIGNAL(prefinishMarkReached(qint32)), SIGNAL(prefinishMarkReached(qint32)));
connect(m_player.data(), SIGNAL(prefinishMarkReached(qint32)), SLOT(handlePrefinishMarkReached(qint32)));
connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64)));
// We need to call setError() after doing the connects, otherwise the
//.........这里部分代码省略.........
示例9: testLocalFile
void MediaSourceTest::testLocalFile()
{
QString filename("/usr/share/sounds/KDE_Beep.ogg");
AbstractMediaStream *stream = 0;
MediaSource a(filename);
QCOMPARE(a.type(), MediaSource::LocalFile);
QCOMPARE(a.fileName(), filename);
QCOMPARE(a.url(), QUrl::fromLocalFile(filename));
QCOMPARE(a.discType(), Phonon::NoDisc);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::LocalFile);
QCOMPARE(b.fileName(), filename);
QCOMPARE(b.url(), QUrl::fromLocalFile(filename));
QCOMPARE(b.discType(), Phonon::NoDisc);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::LocalFile);
QCOMPARE(c.fileName(), filename);
QCOMPARE(c.url(), QUrl::fromLocalFile(filename));
QCOMPARE(c.discType(), Phonon::NoDisc);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
// non-existing files should become invalid sources
filename = "/some/invalid/file.xyz";
MediaSource invalid(filename);
QCOMPARE(invalid.type(), MediaSource::Invalid);
QCOMPARE(invalid.fileName(), QString());
//test that a relative file path is correctly set as an absolute URL
QFile testFile("foo.ogg");
bool deleteFile = false;
if (!testFile.exists()) {
deleteFile = true;
testFile.open(QIODevice::WriteOnly);
testFile.close();
}
filename = "foo.ogg";
MediaSource relative(filename);
//QCOMPARE(relative.fileName(), filename);
QFileInfo urlInfo(relative.url().toLocalFile());
QVERIFY(urlInfo.isAbsolute());
QCOMPARE(urlInfo.fileName(), filename);
QCOMPARE(urlInfo.absolutePath(), QDir::currentPath());
if (deleteFile) {
testFile.remove();
}
}