Line data Source code
1 : #include "VideoListManager.h"
2 : #include <cassert>
3 :
4 12 : void VideoListManager::setFiles(const std::vector<FileEntry>& entries) {
5 12 : files_ = entries;
6 12 : if (selectedIndex_ >= static_cast<int>(files_.size()))
7 1 : selectedIndex_ = -1;
8 12 : }
9 :
10 3 : int VideoListManager::fileCount() const {
11 3 : return static_cast<int>(files_.size());
12 : }
13 :
14 3 : const std::string& VideoListManager::filename(int i) const {
15 3 : assert(i >= 0 && i < static_cast<int>(files_.size()));
16 3 : return files_[static_cast<std::size_t>(i)].filename;
17 : }
18 :
19 3 : double VideoListManager::duration(int i) const {
20 3 : assert(i >= 0 && i < static_cast<int>(files_.size()));
21 3 : return files_[static_cast<std::size_t>(i)].durationSec;
22 : }
23 :
24 9 : int VideoListManager::selectedIndex() const { return selectedIndex_; }
25 :
26 8 : void VideoListManager::setSelectedIndex(int idx) {
27 8 : if (idx < 0 || files_.empty())
28 3 : selectedIndex_ = -1;
29 5 : else if (idx >= static_cast<int>(files_.size()))
30 1 : selectedIndex_ = static_cast<int>(files_.size()) - 1;
31 : else
32 4 : selectedIndex_ = idx;
33 8 : }
34 :
35 4 : VideoListManager::PlayState VideoListManager::playState() const { return playState_; }
36 :
37 4 : void VideoListManager::setPlayState(PlayState s) { playState_ = s; }
38 :
39 5 : bool VideoListManager::isPlaying() const { return playState_ == PlayState::Playing; }
|