-
Notifications
You must be signed in to change notification settings - Fork 957
Expand file tree
/
Copy pathwxMediaCtrl2.h
More file actions
108 lines (73 loc) · 2.35 KB
/
Copy pathwxMediaCtrl2.h
File metadata and controls
108 lines (73 loc) · 2.35 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
// wxMediaCtrl2.h
// libslic3r_gui
//
// Created by cmguo on 2021/12/7.
//
#ifndef wxMediaCtrl2_h
#define wxMediaCtrl2_h
#include "wx/uri.h"
#include "wx/mediactrl.h"
wxDECLARE_EVENT(EVT_MEDIA_CTRL_STAT, wxCommandEvent);
void wxMediaCtrl_OnSize(wxWindow * ctrl, wxSize const & videoSize, int width, int height);
#ifdef __WXMAC__
class wxMediaCtrl2 : public wxWindow
{
public:
wxMediaCtrl2(wxWindow * parent);
~wxMediaCtrl2();
void Load(wxURI url);
void Play();
void Stop();
void SetIdleImage(wxString const & image, wxString const & watermark_text = {});
void SetIdleImage(const wxImage &image, wxString const & watermark_text = {});
wxMediaState GetState() const;
wxSize GetVideoSize() const;
int GetLastError() const { return m_error; }
static const wxMediaState MEDIASTATE_BUFFERING = (wxMediaState) 6;
protected:
void DoSetSize(int x, int y, int width, int height, int sizeFlags) override;
static void bambu_log(void const *ctx, int level, char const *msg);
void NotifyStopped();
private:
void create_player();
void updateIdleLayer();
void updateWatermarkLayer();
void removeIdleLayer();
void * m_player = nullptr;
wxMediaState m_state = wxMEDIASTATE_STOPPED;
int m_error = 0;
wxSize m_video_size{16, 9};
wxString m_idle_image;
wxString m_watermark_text;
void * m_idle_layer = nullptr; // CALayer* for idle image
void * m_watermark_layer = nullptr; // CATextLayer* for watermark
};
#else
class wxMediaCtrl2 : public wxMediaCtrl
{
public:
wxMediaCtrl2(wxWindow *parent);
void Load(wxURI url);
void Play();
void Stop();
void SetIdleImage(wxString const & image, wxString const & watermark_text = {});
void SetIdleImage(const wxImage &image, wxString const & watermark_text = {});
int GetLastError() const;
wxSize GetVideoSize() const;
protected:
wxSize DoGetBestSize() const override;
void DoSetSize(int x, int y, int width, int height, int sizeFlags) override;
#ifdef __WIN32__
WXLRESULT MSWWindowProc(WXUINT nMsg,
WXWPARAM wParam,
WXLPARAM lParam) override;
#endif
private:
wxString m_idle_image;
int m_error = 0;
bool m_loaded = false;
wxSize m_video_size{16, 9};
};
#endif
#endif /* wxMediaCtrl2_h */