MCPcopy Create free account
hub / github.com/Illation/ETEngine / Process

Method Process

Projects/Demo/source/Runtime/PlaylistSystem.cpp:27–98  ·  view source on GitHub ↗

------------------------- PlaylistSystem::Process

Source from the content-addressed store, hash-verified

25// PlaylistSystem::Process
26//
27void PlaylistSystem::Process(fw::ComponentRange<PlaylistSystemView>& range)
28{
29 // common variables
30 core::InputManager* const input = core::InputManager::GetInstance();
31
32 if (input->GetKeyState(E_KbdKey::P) == E_KeyState::Pressed)
33 {
34 for (PlaylistSystemView& view : range)
35 {
36 if (view.source->GetState() != fw::AudioSourceComponent::E_PlaybackState::Playing)
37 {
38 // start playing the first song if it's not playing already
39 if ((view.playlist->currentTrack == std::numeric_limits<size_t>::max()) && view.playlist->tracks.size() > 0u)
40 {
41 view.playlist->currentTrack = 0u;
42
43 view.source->SetAudioData(view.playlist->tracks[view.playlist->currentTrack].GetId());
44 }
45
46 view.source->SetState(fw::AudioSourceComponent::E_PlaybackState::Playing);
47 }
48 else
49 {
50 view.source->SetState(fw::AudioSourceComponent::E_PlaybackState::Paused);
51 }
52 }
53 }
54
55 if (input->GetKeyState(E_KbdKey::LeftBracket) == E_KeyState::Pressed)
56 {
57 for (PlaylistSystemView& view : range)
58 {
59 if (view.playlist->tracks.size() > 0u)
60 {
61 if (view.playlist->currentTrack == std::numeric_limits<size_t>::max())
62 {
63 view.playlist->currentTrack = view.playlist->tracks.size() - 1;
64 }
65 else
66 {
67 view.playlist->currentTrack--;
68 if (view.playlist->currentTrack >= view.playlist->tracks.size())
69 {
70 view.playlist->currentTrack = view.playlist->tracks.size() - 1;
71 }
72 }
73
74 view.source->SetAudioData(view.playlist->tracks[view.playlist->currentTrack].GetId());
75 }
76 }
77 }
78
79 if (input->GetKeyState(E_KbdKey::RightBracket) == E_KeyState::Pressed)
80 {
81 for (PlaylistSystemView& view : range)
82 {
83 if (view.playlist->tracks.size() > 0u)
84 {

Callers

nothing calls this directly

Calls 5

GetKeyStateMethod · 0.80
SetAudioDataMethod · 0.80
GetStateMethod · 0.45
GetIdMethod · 0.45
SetStateMethod · 0.45

Tested by

no test coverage detected