~aleteoryx/muditaos

ref: a9b111aabb905e86678cf6d633e4d435658d69a0 muditaos/module-apps/application-music-player/include/application-music-player/ApplicationMusicPlayer.hpp -rw-r--r-- 2.3 KiB
a9b111aa — Mateusz Piesta [BH-1277] Fix critical battery flow 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Application.hpp>
#include <Audio/decoder/Decoder.hpp>
#include <atomic>

namespace gui
{
    namespace name
    {
        namespace window
        {
            inline constexpr auto track_info_window = "Track Info";
            inline constexpr auto all_songs_window = "All Songs";
        }; // namespace window
    };     // namespace name
};         // namespace gui

namespace app
{
    namespace music_player::internal
    {
        class MusicPlayerPriv;
    }

    inline constexpr auto name_music_player = "ApplicationMusicPlayer";

    class ApplicationMusicPlayer : public Application
    {

      public:
        explicit ApplicationMusicPlayer(std::string name                    = name_music_player,
                                        std::string parent                  = {},
                                        StatusIndicators statusIndicators   = StatusIndicators{},
                                        StartInBackground startInBackground = {false});
        ~ApplicationMusicPlayer() override;

        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl,
                                                [[maybe_unused]] sys::ResponseMessage *resp) override;
        sys::ReturnCodes InitHandler() override;
        sys::ReturnCodes DeinitHandler() override;

        sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override
        {
            return sys::ReturnCodes::Success;
        }

        void createUserInterface() final;
        void destroyUserInterface() final;

        void handlePlayResponse(sys::Message *msg);
        void handleStopResponse(sys::Message *msg);

      private:
        std::unique_ptr<music_player::internal::MusicPlayerPriv> priv;
    };

    template <> struct ManifestTraits<ApplicationMusicPlayer>
    {
        static auto GetManifest() -> manager::ApplicationManifest
        {
            return {{manager::actions::Launch,
                     manager::actions::PhoneModeChanged,
                     manager::actions::BluetoothModeChanged,
                     manager::actions::AlarmClockStatusChanged},
                    locks::AutoLockPolicy::DetermineByWindow};
        }
    };
} /* namespace app */