void DownloadItem::speedCheck() { if (!m_reply) return; int bytesTotal = m_reply->size(); int bufferSize = initialBufferSize(); if (bufferSize > bytesTotal) bufferSize = 0; if (m_bytesReceived < bufferSize / 3) { stop(); // too slow! retry qDebug() << "Retrying..."; connect(video, SIGNAL(gotStreamUrl(QUrl)), SLOT(gotStreamUrl(QUrl)), Qt::UniqueConnection); video->loadStreamUrl(); } }
void VideoDetailsModel::retriveRealUrl() { Video *video = new Video; QUrl videoUrl(m_videoUrl); video->setWebpage(videoUrl); video->loadStreamUrl(); connect(video, SIGNAL(gotStreamUrl(QUrl)), this, SLOT(streamUrl(QUrl))); }
void MediaView::pause() { #ifdef APP_PHONON switch( mediaObject->state() ) { case Phonon::PlayingState: mediaObject->pause(); pauseTimer.start(); break; default: if (pauseTimer.hasExpired(60000)) { pauseTimer.invalidate(); connect(playlistModel->activeVideo(), SIGNAL(gotStreamUrl(QUrl)), SLOT(resumeWithNewStreamUrl(QUrl))); playlistModel->activeVideo()->loadStreamUrl(); } else mediaObject->play(); break; } #endif }
void MediaView::activeRowChanged(int row) { if (stopped) return; errorTimer->stop(); #ifdef APP_PHONON mediaObject->stop(); #endif if (downloadItem) { downloadItem->stop(); delete downloadItem; downloadItem = 0; currentVideoSize = 0; } Video *video = playlistModel->videoAt(row); if (!video) return; videoAreaWidget->showLoading(video); connect(video, SIGNAL(gotStreamUrl(QUrl)), SLOT(gotStreamUrl(QUrl)), Qt::UniqueConnection); connect(video, SIGNAL(errorStreamUrl(QString)), SLOT(skip()), Qt::UniqueConnection); video->loadStreamUrl(); // video title in titlebar MainWindow::instance()->setWindowTitle(video->title() + " - " + Constants::NAME); // ensure active item is visible if (row != -1) { QModelIndex index = playlistModel->index(row, 0, QModelIndex()); playlistView->scrollTo(index, QAbstractItemView::EnsureVisible); } // enable/disable actions The::globalActions()->value("download")->setEnabled( DownloadManager::instance()->itemForVideo(video) == 0); The::globalActions()->value("previous")->setEnabled(row > 0); The::globalActions()->value("stopafterthis")->setEnabled(true); The::globalActions()->value("related-videos")->setEnabled(true); bool enableDownload = video->license() == Video::LicenseCC; #ifdef APP_ACTIVATION enableDownload = enableDownload || Activation::instance().isLegacy(); #endif #ifdef APP_DOWNLOADS enableDownload = true; #endif QAction *a = The::globalActions()->value("download"); a->setEnabled(enableDownload); a->setVisible(enableDownload); updateSubscriptionAction(video, YTChannel::isSubscribed(video->channelId())); foreach (QAction *action, currentVideoActions) action->setEnabled(true); #ifndef APP_PHONON_SEEK QSlider *slider = MainWindow::instance()->getSlider(); slider->setEnabled(false); slider->setValue(0); #endif if (snapshotSettings) { delete snapshotSettings; snapshotSettings = 0; MainWindow::instance()->adjustStatusBarVisibility(); } // see you in gotStreamUrl... }