void MediaPlayerActivity::onSelectionChanged(const MediaFileRef & file) { if (bt::Exists(file.path())) play_action->setEnabled((action_flags & kt::MEDIA_PLAY) || file != media_player->getCurrentSource()); else if (!file.path().isEmpty()) play_action->setEnabled(action_flags & kt::MEDIA_PLAY); else play_action->setEnabled(false); }
QModelIndex PlayListWidget::play() { QModelIndex pidx = view->currentIndex(); QModelIndex idx = proxy_model->mapToSource(pidx); MediaFileRef file = play_list->fileForIndex(idx); if (!file.path().isEmpty()) { player->play(file); } return pidx; }
bool MediaViewFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { if (show_incomplete) return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); MediaModel* model = (MediaModel*)sourceModel(); MediaFileRef ref = model->fileForIndex(model->index(source_row)); MediaFile::Ptr file = ref.mediaFile(); if (file->fullyAvailable()) return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); else return false; }
void MediaPlayerActivity::onDoubleClicked(const MediaFileRef & file) { if (bt::Exists(file.path())) { play(file); } }
void MediaPlayerActivity::play(const MediaFileRef & file) { media_player->play(file); QModelIndex idx = play_list->indexForFile(file.path()); if (idx.isValid()) { curr_item = idx; bool random = play_list->randomOrder(); QModelIndex n = play_list->next(curr_item,random); next_action->setEnabled(n.isValid()); } }
void MediaController::playing(const MediaFileRef& file) { if (file.path().isEmpty()) { stopped(); } else { current_file = file; metaDataChanged(); } }
void MediaPlayerActivity::enableActions(unsigned int flags) { pause_action->setEnabled(flags & kt::MEDIA_PAUSE); stop_action->setEnabled(flags & kt::MEDIA_STOP); play_action->setEnabled(false); QModelIndex idx = play_list->selectedItem(); if (idx.isValid()) { PlayList* pl = play_list->playList(); MediaFileRef file = pl->fileForIndex(idx); if (bt::Exists(file.path())) play_action->setEnabled((flags & kt::MEDIA_PLAY) || file != media_player->getCurrentSource()); else play_action->setEnabled(action_flags & kt::MEDIA_PLAY); } else play_action->setEnabled(flags & kt::MEDIA_PLAY); prev_action->setEnabled(flags & kt::MEDIA_PREV); action_flags = flags; }
void PlayListWidget::doubleClicked(const QModelIndex & index) { MediaFileRef file = play_list->fileForIndex(proxy_model->mapToSource(index)); if (!file.path().isEmpty()) doubleClicked(file); }