[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/network/videocatcher/src
From: Jonas Emanuel Müller <zanoi () zanoi ! net>
Date: 2010-12-06 15:30:12
Message-ID: 20101206153012.7EF00AC8A4 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1204272 by jonasemuller:
add support for playback while downloading
M +30 -9 mainwindowkde.cpp
--- trunk/playground/network/videocatcher/src/mainwindowkde.cpp #1204271:1204272
@@ -392,15 +392,29 @@
if(videoPath != "") {
KMimeType::Ptr mimeType;
+ QString mimeTypeName;
//note that the fourth parameter enables fast_mode
//which means that no disk access is allowed
//this is to prevent constant disk access, but might
//be changed later.
- mimeType = KMimeType::findByUrl(videoPath, 0, true, true);
- updatePlayMenu(mimeType.data()->name());
+ mimeType = KMimeType::findByUrl(videoPath, 0, true, true); //try finding \
mime type with file path + mimeTypeName = mimeType.data()->name();
+ kDebug() << "found mimetype to be " << mimeTypeName << " on first try";
+ if(mimeTypeName == "" || mimeTypeName == "application/octet-stream") { \
//finding mime type failed + QString videoUrl = \
d->m_episodeModel->videoUrl(current); + mimeType = \
KMimeType::findByUrl(videoUrl, 0); //try finding mime type with url + \
mimeTypeName = mimeType.data()->name(); + kDebug() << "found mimetype to \
be " << mimeTypeName << " on second try"; + if(mimeTypeName == "" || \
mimeTypeName == "application/octet-stream") { //finding mime type failed + \
mimeTypeName = KIO::NetAccess::mimetype(videoUrl, this); + kDebug() << \
"found mimetype to be " << mimeTypeName << " on third try"; }
}
+ updatePlayMenu(mimeTypeName);
+ }
+}
+
void MainWindow::updateEpisodeView()
{
QModelIndex index = d->m_channelView->currentIndex();
@@ -452,7 +466,7 @@
break;
default: //should be downloading, but in case there is an invalid state \
catch it anyway action("download")->setEnabled(false);
- action("play")->setEnabled(false);
+ action("play")->setEnabled(true);
action("delete")->setEnabled(false);
action("cancel")->setEnabled(true);
action("stream")->setEnabled(true);
@@ -757,7 +771,7 @@
d->m_jobs->insert(job, videoUrl);
d->m_episodeModel->setStatus(index, 0); //set download status to 0% downloadeed
- d->m_episodeModel->setVideoPath(index, videoPath.pathOrUrl());
+ d->m_episodeModel->setVideoPath(index, videoPath.pathOrUrl() + ".part");
submitEpisodes();
updateActions();
@@ -792,18 +806,23 @@
{
QString url = d->m_jobs->value(job);
QModelIndex index = d->m_originalEpisodeModel->findByUrl(url);
+ QString videopath = d->m_originalEpisodeModel->videoPath(index);
if (job->error()) {
d->m_originalEpisodeModel->setStatus(index, Episode_Status_Not_Downloaded);
- QString videopath = d->m_originalEpisodeModel->videoPath(index);
d->m_originalEpisodeModel->setVideoPath(index, "");
- bool success = KIO::NetAccess::del(videopath + ".part", this);
+ if(KIO::NetAccess::exists(videopath, true, this)) {
+ bool success = KIO::NetAccess::del(videopath, this);
if(!success) {
- //FIXME: don't handle this error?
+ //dont handle this error?
qWarning() << "couldn't delete partially downloaded file";
}
+ }
} else {
d->m_originalEpisodeModel->setStatus(index, Episode_Status_Downloaded);
+ QString newPath(videopath);
+ newPath.chop(5); //remove the ".part" fomr the video path
+ d->m_originalEpisodeModel->setVideoPath(index, newPath);
}
#if KDE_IS_VERSION(4,4,0)
@@ -855,11 +874,13 @@
QString videopath = d->m_originalEpisodeModel->videoPath(index);
d->m_originalEpisodeModel->setVideoPath(index, "");
- bool success = KIO::NetAccess::del(videopath + ".part", this);
+ if(KIO::NetAccess::exists(videopath, true, this)) {
+ bool success = KIO::NetAccess::del(videopath, this);
if(!success) {
- //FIXME: don't handle this error?
+ //dont handle this error?
qWarning() << "couldn't delete partially downloaded file";
}
+ }
d->m_episodeView->setCurrentIndex(d->m_episodeModel->mapFromSource(index));
submitEpisodes();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic