-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMikModMedia.cpp
More file actions
159 lines (144 loc) · 5.71 KB
/
MikModMedia.cpp
File metadata and controls
159 lines (144 loc) · 5.71 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//---------------------------------------------------------------------------
#pragma hdrstop
#include "MikModMedia.h"
#include "MikMod.h"
//---------------------------------------------------------------------------
#if defined(_WINDOWS_)
#pragma comment(lib, "TMikModLib")
#define MODULEDRIVER TModuleDriver::Windows
#elif defined(__ANDROID__)
#define MODULEDRIVER TModuleDriver::OpenSLES
#else
#pragma link "TMikModLib"
#define MODULEDRIVER TModuleDriver::MacOSX
#endif
//---------------------------------------------------------------------------
#pragma package(smart_init)
/**
* Register Media Codec Class.
*/
void AutoRegMediaCodecClass()
{
TMediaCodecManager::RegisterMediaCodecClass(".669", "Composer 669 File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".amf", "DSMI Advanced Module Format File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".dsm", "DSIK Internal Format File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".far", "Farandole Composer File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".gdm", "General DigiMusic File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".imf", "Imago Orpheus File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".it", "Impulse Tracker File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".med", "OctaMED File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".mod", "MOD File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".mtm", "MultiTracker Module File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".okta", "Amiga Oktalyzer File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".s3m", "Scream Tracker 3 File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".stm", "Scream Tracker File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".stx", "Scream Tracker Music Interface Kit File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".ult", "UltraTracker File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".uni", "MikMod File", TMediaType::Audio, __classid(TMikModMediaCodec));
TMediaCodecManager::RegisterMediaCodecClass(".xm", "FastTracker 2 File", TMediaType::Audio, __classid(TMikModMediaCodec));
}
#pragma startup AutoRegMediaCodecClass
/**
* Creates a TMikModMedia from a given file.
* @param AFileName The parameter specifies the name of the file from which to create the TMikModMedia.
* @return A TMedia created from a specified file.
*/
TMedia* __fastcall TMikModMediaCodec::CreateFromFile(const System::UnicodeString AFileName)
{
return new TMikModMedia(AFileName);
}
/**
* Constructor.
* @param AFileName The media file.
*/
__fastcall TMikModMedia::TMikModMedia(const System::UnicodeString AFileName) :
Media::TMedia(AFileName)
{
FMikMod = new TMikMod(MODULEDRIVER);
FMikMod->LoadFromFile(AFileName, 32);
}
/**
* Destructor.
*/
__fastcall TMikModMedia::~TMikModMedia(void)
{
delete FMikMod;
}
/**
* Getter function for the Duration property.
* @return The total play time of the current media file.
*/
__int64 __fastcall TMikModMedia::GetDuration(void)
{
return FMikMod->NumberPos;
}
/**
* Getter function for the CurrentTime property.
* @return The current playback position.
*/
__int64 __fastcall TMikModMedia::GetCurrent(void)
{
return FMikMod->SongPosition;
}
/**
* Setter function for the CurrentTime property.
* @param Value Specifies the new value for CurrentTime.
*/
void __fastcall TMikModMedia::SetCurrent(const __int64 Value)
{
FMikMod->SongPosition = Value;
}
/**
* Getter function for the VideoSize property.
* @return The media file is audio only and does not have a window, so the VideoSize is (0,0).
*/
System::Types::TPointF __fastcall TMikModMedia::GetVideoSize(void)
{
return TPointF(0, 0);
}
/**
* Getter function for the State property.
* @return If the current media file is playing, then State is set to Playing, otherwise it is set to Stopped.
*/
TMediaState __fastcall TMikModMedia::GetMediaState(void)
{
return FMikMod->Active ? TMediaState::Playing : TMediaState::Stopped;
}
/**
* Getter function for the Volume property.
* @return The audio volume of the current media file.
*/
float __fastcall TMikModMedia::GetVolume(void)
{
return FMikMod->Volume / 128.0f;
}
/**
* Setter function for the Volume property.
* @param Value Specifies the new value of Volume.
*/
void __fastcall TMikModMedia::SetVolume(const float Value)
{
FMikMod->Volume = Value * 128;
}
/**
* Updates the current Media, depending on the TMediaPlayerControl associated with it.
* The TMediaPlayerControl associated with the current media is specified through the Control property.
*/
void __fastcall TMikModMedia::UpdateMediaFromControl()
{
inherited::UpdateMediaFromControl();
}
/**
* Plays the current media file.
*/
void __fastcall TMikModMedia::DoPlay(void)
{
FMikMod->Start();
}
/**
* Stops the current media from being played.
*/
void __fastcall TMikModMedia::DoStop(void)
{
FMikMod->Stop();
}