void tst_QMediaContent::testResources() { QMediaResourceList resourceList; resourceList << QMediaResource(QUrl("http://example.com/movie-main.mov")); resourceList << QMediaResource(QUrl("http://example.com/movie-big.mov")); QMediaContent media(resourceList); QMediaResourceList res = media.resources(); QCOMPARE(res.size(), 2); QCOMPARE(res[0], QMediaResource(QUrl("http://example.com/movie-main.mov"))); QCOMPARE(res[1], QMediaResource(QUrl("http://example.com/movie-big.mov"))); }
void tst_QMediaContent::testCopy() { QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); QMediaContent media2(media1); QVERIFY(media1 == media2); }
void MainWindow::on_pushButton_AddFile_clicked() { QMediaResource mediaresource; if(playlist_names.empty()){ playlist_names = QFileDialog::getOpenFileNames(this, tr("Audio"),QDir::rootPath(),"Audio (*.mp3 *.wav *.aiff *.flac *.ogg *.wma)"); for (int i = 0; i < playlist_names.size(); ++i){ QString file = playlist_names.at(i); mediaresource = QMediaResource(QUrl(file)); audioplayer.addMedia(file); treeView_tracks->add_track(file,i); } audioplayer.setCurrentIndex(0); } else{ QStringList aux = QFileDialog::getOpenFileNames(this, tr("Audio"),QDir::rootPath(),"Audio (*.mp3 *.wav *.aiff *.flac *.ogg *.wma))"); int prev_numtracks = playlist_names.count(); playlist_names = playlist_names+aux; for (int i = 0; i < aux.size(); ++i){ QString file = aux.at(i); audioplayer.addMedia(file); treeView_tracks->add_track(file,i+prev_numtracks); } } calculate_total_length(); }
void tst_QMediaContent::testNull() { QMediaContent media; QCOMPARE(media.isNull(), true); QCOMPARE(media.canonicalUrl(), QUrl()); QCOMPARE(media.canonicalResource(), QMediaResource()); QCOMPARE(media.resources(), QMediaResourceList()); }
void tst_QMediaContent::testResourceListCtor() { QMediaResourceList resourceList; resourceList << QMediaResource(QUrl("http://example.com/movie.mov")); QMediaContent media(resourceList); QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); }
QMediaContent QWmpPlayerControl::media() const { QMediaResourceList resources; QUrl tmpUrl = url(); if (!tmpUrl.isEmpty()) resources << QMediaResource(tmpUrl); return resources; }
void tst_QMediaContent::testAssignment() { QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); QMediaContent media2; QMediaContent media3; media2 = media1; QVERIFY(media2 == media1); media2 = media3; QVERIFY(media2 == media3); }
void tst_QMediaContent::testEquality() { QMediaContent media1; QMediaContent media2; QMediaContent media3(QMediaResource(QUrl("http://example.com/movie.mov"))); QMediaContent media4(QMediaResource(QUrl("http://example.com/movie.mov"))); QMediaContent media5(QMediaResource(QUrl("file:///some/where/over/the/rainbow.mp3"))); // null == null QCOMPARE(media1 == media2, true); QCOMPARE(media1 != media2, false); // null != something QCOMPARE(media1 == media3, false); QCOMPARE(media1 != media3, true); // equiv QCOMPARE(media3 == media4, true); QCOMPARE(media3 != media4, false); // not equiv QCOMPARE(media4 == media5, false); QCOMPARE(media4 != media5, true); }
QMediaContentPrivate(QMediaPlaylist *pls, const QUrl &url, bool isOwn): playlist(pls), isPlaylistOwned(isOwn) { resources << QMediaResource(url); }
QMediaResource QMediaContent::canonicalResource() const { return d.constData() != 0 ? d->resources.value(0) : QMediaResource(); }
QMediaContent::QMediaContent(const QNetworkRequest &request): d(new QMediaContentPrivate) { d->resources << QMediaResource(request); }
QMediaContent::QMediaContent(const QUrl &url): d(new QMediaContentPrivate) { d->resources << QMediaResource(url); }
void tst_QMediaContent::testResourceCtor() { QMediaContent media(QMediaResource(QUrl("http://example.com/movie.mov"))); QCOMPARE(media.canonicalResource(), QMediaResource(QUrl("http://example.com/movie.mov"))); }