Beispiel #1
0
QList<PlayListItem *> PlayListModel::urlToItems(QUrl url)
{
    QList<PlayListItem *> new_items;

    if (url.isLocalFile()) {
        QFileInfo f(url.path());
        if (f.isDir()) {
            QDirIterator iterator(url.path(), QDirIterator::Subdirectories);
            while (iterator.hasNext()) {
                iterator.next();
                if (!iterator.fileInfo().isDir()) {
                    new_items += urlToItems(QUrl::fromLocalFile(iterator.filePath()));
                }
            }
        } else {
            PlayListItem *p = new PlayListItem(url);
            if (p->isValid()) {
                p->ensureHistogram();
                new_items += p;
            }
        }
    } else {
        new_items += new PlayListItem(url);
    }

    return new_items;
}
Beispiel #2
0
size_t PlayListStep::GetLengthMS() const
{
    int msPerFrame = 1000;
    PlayListItem* timesource = GetTimeSource(msPerFrame);
    if (timesource != nullptr)
    {
        return timesource->GetDurationMS();
    }
    else
    {
        size_t len = 0;
        for (auto it = _items.begin(); it != _items.end(); ++it)
        {
            len = std::max(len, (*it)->GetDurationMS());
        }

        if (len == 0)
        {
            for (auto it = _items.begin(); it != _items.end(); ++it)
            {
                len = std::max(len, (*it)->GetDurationMS(msPerFrame));
            }

            if (len == 0) len = msPerFrame;
        }

        return len;
    }
}
Beispiel #3
0
size_t PlayListStep::GetPosition() const
{
    int msPerFrame = 1000;
    PlayListItem* timesource = GetTimeSource(msPerFrame);

    size_t frameMS;
    if (timesource != nullptr)
    {
        frameMS = timesource->GetPositionMS();
    }
    else
    {
        auto now = wxGetUTCTimeMillis();
        if (_pause == 0)
        {
            frameMS = (now - _startTime).ToLong();
        }
        else
        {
            frameMS = (now - _startTime - (now - _pause)).ToLong();
        }
    }

    return frameMS;
}
Beispiel #4
0
bool PlayListStep::Frame(wxByte* buffer, size_t size)
{
    int msPerFrame = 1000;
    PlayListItem* timesource = GetTimeSource(msPerFrame);

    if (msPerFrame == 0)
    {
        msPerFrame = 50;
    }

    size_t frameMS;
    if (timesource != nullptr)
    {
        frameMS = timesource->GetPositionMS();
    }
    else
    {
        frameMS = (wxGetUTCTimeMillis() - _startTime).ToLong();
    }

    for (auto it = _items.begin(); it != _items.end(); ++it)
    {
        (*it)->Frame(buffer, size, frameMS, msPerFrame);
    }

    if (timesource != nullptr)
    {
        return timesource->Done();
    }
    else
    {
        return frameMS >= GetLengthMS();
    }
}
Beispiel #5
0
void PlayList::remove(const QString &url)
{
    for (int i = mpModel->rowCount() - 1; i >= 0; --i) {
        PlayListItem item = mpModel->data(mpModel->index(i), Qt::DisplayRole).value<PlayListItem>();
        if (item.url() == url) {
            mpModel->removeRow(i);
        }
    }
}
Beispiel #6
0
void PlayList::insert(const QString &url, int row)
{
    PlayListItem item;
    item.setUrl(url);
    item.setDuration(0);
    item.setLastTime(0);
    QString title = url;
    if (!url.contains("://") || url.startsWith("file://")) {
        title = QFileInfo(url).fileName();
    }
    item.setTitle(title);
    insertItemAt(item, row);
}
Beispiel #7
0
bool PlayListModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if (index.isValid() && role == Qt::EditRole) {
        PlayListItem *i = items[index.row()];

        i->setColumn(index.column(), value.toString());

        emit(dataChanged(index, index));
        return true;
    }

    return false;
}
Beispiel #8
0
QVariant PlayListModel::data(const QModelIndex &index, int role) const
{
    if (role == Qt::DisplayRole) {
        PlayListItem *i = items[index.row()];
        return i->getColumn(index.column());
    } else if (role == Qt::BackgroundRole && index.row() == current) {
        return QVariant(QColor(152,209,117));
    } else if (role == Qt::EditRole) {
        PlayListItem *i = items[index.row()];
        return i->getColumn(index.column());
    }

    return QVariant();
}
Beispiel #9
0
void PlayerWindow::play(const QString &name)
{

    mFile = name;

    mTitle = mFile;

    if (!mFile.contains(QLatin1String("://")) || mFile.startsWith(QLatin1String("file://"))) {
        mTitle = QFileInfo(mFile).fileName();
    }

    setWindowTitle(mTitle);

    PlayListItem item;
    item.setUrl(mFile);
    item.setTitle(mTitle);
    item.setLastTime(0);

    //m_vo->setOrientation(180);


    m_player->play(name);
    m_player2->play(name);
    m_player2->setVideoStream(1);
    m_player2->audio()->setMute(true);



    //totalTime->setText(QString::number(m_player->duration()));
    m_playBtn->setStyleSheet("QPushButton { border-image: url(:/images/images/music_player/pause_hover_and_active.png);}");

    currentTime->setText("00:00:00");
    totalTime->setText("00:00:00");
    //m_vo->setOutAspectRatio(1.42529);
    m_vo->setOutAspectRatio(double(m_vo->widget()->width())/double(m_vo->widget()->height()));
    m_vo2->setOutAspectRatio(double(m_vo2->widget()->width())/double(m_vo2->widget()->height()));
    if (mpPlayList->isClicked){
        rowForPlay = mpPlayList->rowIndex;
    }
    if (mpPlayListEvent->isClicked){
        rowForPlay = mpPlayListEvent->rowIndex;
    }

    container->show();

}
Beispiel #10
0
PlayListItem* PlayListStep::GetTimeSource(int &ms) const
{
    PlayListItem* timesource = nullptr;
    ms = 9999;
    for (auto it = _items.begin(); it != _items.end(); ++it)
    {
        if ((*it)->ControlsTiming())
        {
            if (timesource == nullptr)
            {
                timesource = *it;
                ms = (*it)->GetFrameMS();
            }
            else
            {
                if ((*it)->GetPriority() > timesource->GetPriority())
                {
                    timesource = *it;
                    ms = (*it)->GetFrameMS();
                }
            }
        }
        else if (timesource == nullptr)
        {
            if ((*it)->GetFrameMS() != 0 && (*it)->GetFrameMS() < ms)
            {
                ms = (*it)->GetFrameMS();
            }
        }
           
    }

    if (ms == 9999)
    {
        ms = 50;
    }

    return timesource;
}