virtual QMediaContent media(int) const { return QMediaContent(); }
示例#2
0
void PlaybackWidget::setMedia(const QString &str)
{
    setMedia(QMediaContent(QUrl(str)));
}
示例#3
0
 foreach (const QString &f, files) {
     m_playlist->addMedia(QMediaContent(QUrl::fromLocalFile(dir.absolutePath() + "/" + f)));
     emit tracksChanged(tracks());
     emit trackCountChanged(trackCount());
 }
示例#4
0
void GrlMedia::clearFile()
{
	m_player->setMedia(QMediaContent());
}
示例#5
0
void VideoThumbnailer::Private::slotProcessframe(QVideoFrame frm)
{
    if (player->mediaStatus() != QMediaPlayer::BufferedMedia ||
        player->position()    <= 0)
    {
        if (++errorCount > 1000)
        {
            qCDebug(DIGIKAM_GENERAL_LOG) << "Error: Video data are corrupted from " << fileName();
            isReady = true;
            player->setMedia(QMediaContent());
            dd->emit signalThumbnailFailed(filePath());
            return;
        }
        else
        {
            player->setPosition(++position);
            return;
        }
    }

    qCDebug(DIGIKAM_GENERAL_LOG) << "Video frame extraction from " << fileName()
                                 << " at position " << position;

    if (!frm.isValid())
    { 
        qCDebug(DIGIKAM_GENERAL_LOG) << "Error: Video frame is not valid.";
        isReady = true;
        player->setMedia(QMediaContent());
        dd->emit signalThumbnailFailed(filePath());
        return;
    }

    QImage img = imageFromVideoFrame(frm);

    if (!img.isNull())
    {
        img = img.scaled(thumbSize, thumbSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);

        if (createStrip && img.width() > strip.width() && img.height() > strip.height())
        {
            // Add a video strip on the left side of video thumb.

            for (int y = 0; y < img.height(); y += strip.height())
            {
                for (int ys = 0 ; ys < strip.height() ; ys++)
                {
                    int pos = y + ys;

                    if (pos < img.height())
                    {
                        memcpy((void*)img.constScanLine(pos), (void*)strip.constScanLine(ys), strip.bytesPerLine());
                    }
                }
            }
        }

        qCDebug(DIGIKAM_GENERAL_LOG) << "Video frame extracted with size " << img.size();

        isReady = true;
        player->setMedia(QMediaContent());
        dd->emit signalThumbnailDone(filePath(), img.copy());
    }
    else
    {
        qCDebug(DIGIKAM_GENERAL_LOG) << "Video frame format is not supported: " << frm;

        isReady = true;
        player->setMedia(QMediaContent());
        dd->emit signalThumbnailFailed(filePath());
    }
}
示例#6
0
void VideoThumbnailer::Private::slotMediaStatusChanged(QMediaPlayer::MediaStatus state)
{
    if (player->currentMedia() != media)
    {
        return;
    }

    switch (state)
    {
        case QMediaPlayer::LoadedMedia:
        {
            if (!player->isVideoAvailable())
            {
                qCDebug(DIGIKAM_GENERAL_LOG) << "Video stream is not available for " << fileName();
                isReady = true;
                player->setMedia(QMediaContent());
                dd->emit signalThumbnailFailed(filePath());
                return;
            }

            errorCount =  0;
            position   = -1;

            player->pause();

            break;
        }
        case QMediaPlayer::BufferedMedia:
        {
            if (!player->isSeekable())
            {
                qCDebug(DIGIKAM_GENERAL_LOG) << "Video seek is not available for " << fileName();
                isReady = true;
                player->setMedia(QMediaContent());
                dd->emit signalThumbnailFailed(filePath());
                return;
            }

            if (player->duration() <= 0)
            {
                qCDebug(DIGIKAM_GENERAL_LOG) << "Video has no valid duration for " << fileName();
                isReady = true;
                player->setMedia(QMediaContent());
                dd->emit signalThumbnailFailed(filePath());
                return;
            }

            qCDebug(DIGIKAM_GENERAL_LOG) << "Video duration for " << fileName() << "is " << player->duration() << " seconds";

            position = (qint64)(player->duration() * 0.2);

            player->setPosition(position);    // Seek to 20% of the media to take a thumb.

            qCDebug(DIGIKAM_GENERAL_LOG) << "Trying to get thumbnail from " << fileName() << " at position " << position;

            break;
        }
        case QMediaPlayer::InvalidMedia:
        {
            qCDebug(DIGIKAM_GENERAL_LOG) << "Video cannot be decoded for " << fileName();
            isReady = true;
            player->setMedia(QMediaContent());
            dd->emit signalThumbnailFailed(filePath());
        }
        default:
            break;
    }
}
示例#7
0
void SearchDialog::trackWasDoubleClicked(const QModelIndex &track)
{
	Playlist *p = _viewPlaylists->tabPlaylists->currentPlayList();
	p->insertMedias(-1, { QMediaContent(QUrl::fromLocalFile(track.data(Miam::DF_URI).toString())) });
	this->clear();
}
示例#8
0
void MyPlayer::setCurrentIndex(int index)
{
    this->currentindex = index;
    this->player.setMedia(QMediaContent(list[currentList][index]));
}