void Session::deferPlayMedia(Transfer t, int fileIndex) { if (t.is_valid() && !playMedia(t, fileIndex)) { qDebug() << "Defer playing file: " << t.filename_at(fileIndex); t.set_sequential_download(false); t.prioritize_extremity_pieces(true, fileIndex); t.set_eager_mode(true); m_pending_medias.insert(qMakePair(t.hash(), fileIndex)); } }
bool Session::playMedia(Transfer t, int fileIndex) { if (t.is_valid() && t.has_metadata() && misc::isPreviewable(misc::file_extension(t.filename_at(fileIndex)))) { TransferBitfield pieces = t.pieces(); const std::vector<int> extremity_pieces = t.file_extremity_pieces_at(fileIndex); // check we have all boundary pieces for the file foreach (int p, extremity_pieces) if (!pieces[p]) return false; t.set_sequential_download(true); return QDesktopServices::openUrl(QUrl::fromLocalFile(t.absolute_files_path().at(fileIndex))); }