+ QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
+ QString tempFile = tempDir + "/minitube.mp4";
+ if (!QFile::remove(tempFile)) {
+ qDebug() << "Cannot remove temp file";
+ }
+
+ Video *videoCopy = video->clone();
+ if (downloadItem) delete downloadItem;
+ downloadItem = new DownloadItem(videoCopy, streamUrl, tempFile, this);
+ connect(downloadItem, SIGNAL(statusChanged()), SLOT(downloadStatusChanged()));
+ // connect(downloadItem, SIGNAL(progress(int)), SLOT(downloadProgress(int)));
+ // connect(downloadItem, SIGNAL(finished()), SLOT(itemFinished()));
+ downloadItem->start();
+
+}
+
+/*
+void MediaView::downloadProgress(int percent) {
+ MainWindow* mainWindow = dynamic_cast<MainWindow*>(window());
+
+ mainWindow->getSeekSlider()->setStyleSheet(" QSlider::groove:horizontal {"
+ "border: 1px solid #999999;"
+ // "border-left: 50px solid rgba(255, 0, 0, 128);"
+ "height: 8px;"
+ "background: qlineargradient(x1:0, y1:0, x2:.5, y2:0, stop:0 rgba(255, 0, 0, 92), stop:"
+ + QString::number(percent/100.0) +
+
+ " rgba(255, 0, 0, 92), stop:" + QString::number((percent+1)/100.0) + " transparent, stop:1 transparent);"
+ "margin: 2px 0;"
+ "}"
+ "QSlider::handle:horizontal {"
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);"
+ "border: 1px solid #5c5c5c;"
+ "width: 16px;"
+ "height: 16px;"
+ "margin: -2px 0;"
+ "border-radius: 8px;"
+ "}"
+
+ );
+}
+
+*/
+
+void MediaView::downloadStatusChanged() {
+ switch(downloadItem->status()) {
+ case Downloading:
+ startPlaying();
+ break;
+ case Starting:
+ qDebug() << "Starting";
+ break;
+ case Finished:
+ qDebug() << "Finished";
+ break;
+ case Failed:
+ qDebug() << "Failed";
+ case Idle:
+ qDebug() << "Idle";
+ break;
+ }
+}
+
+void MediaView::startPlaying() {
+ if (reallyStopped) return;
+