@@ -96,36 +96,44 @@ class AudioplayersTizenPlugin : public flutter::Plugin {
96
96
AudioPlayer *player = GetAudioPlayer (player_id, mode);
97
97
98
98
try {
99
- const auto &method_name = method_call.method_name ();
99
+ const std::string &method_name = method_call.method_name ();
100
100
if (method_name == " play" ) {
101
101
double volume = 0.0 ;
102
- std::string url;
103
- int32_t position = 0 ;
104
102
if (GetValueFromEncodableMap (arguments, " volume" , volume)) {
105
103
player->SetVolume (volume);
106
104
}
105
+
106
+ std::string url;
107
107
if (GetValueFromEncodableMap (arguments, " url" , url)) {
108
108
player->SetUrl (url);
109
109
}
110
+
110
111
player->Play ();
112
+
113
+ int32_t position = 0 ;
111
114
if (GetValueFromEncodableMap (arguments, " position" , position)) {
112
115
player->Seek (position);
113
116
}
117
+
114
118
result->Success (flutter::EncodableValue (1 ));
115
119
} else if (method_name == " playBytes" ) {
116
120
double volume = 0.0 ;
117
- std::vector<uint8_t > bytes;
118
- int32_t position = 0 ;
119
121
if (GetValueFromEncodableMap (arguments, " volume" , volume)) {
120
122
player->SetVolume (volume);
121
123
}
124
+
125
+ std::vector<uint8_t > bytes;
122
126
if (GetValueFromEncodableMap (arguments, " bytes" , bytes)) {
123
127
player->SetDataSource (bytes);
124
128
}
129
+
125
130
player->Play ();
131
+
132
+ int32_t position = 0 ;
126
133
if (GetValueFromEncodableMap (arguments, " position" , position)) {
127
134
player->Seek (position);
128
135
}
136
+
129
137
result->Success (flutter::EncodableValue (1 ));
130
138
} else if (method_name == " resume" ) {
131
139
player->Play ();
@@ -178,15 +186,16 @@ class AudioplayersTizenPlugin : public flutter::Plugin {
178
186
return iter->second .get ();
179
187
}
180
188
181
- PreparedListener prepared_listener =
182
- [channel = channel_.get ()](const std::string &player_id, int duration) {
183
- flutter::EncodableMap wrapped = {{flutter::EncodableValue (" playerId" ),
184
- flutter::EncodableValue (player_id)},
185
- {flutter::EncodableValue (" value" ),
186
- flutter::EncodableValue (duration)}};
187
- auto arguments = std::make_unique<flutter::EncodableValue>(wrapped);
188
- channel->InvokeMethod (" audio.onDuration" , std::move (arguments));
189
- };
189
+ PreparedListener prepared_listener = [channel = channel_.get ()](
190
+ const std::string &player_id,
191
+ int32_t duration) {
192
+ flutter::EncodableMap wrapped = {{flutter::EncodableValue (" playerId" ),
193
+ flutter::EncodableValue (player_id)},
194
+ {flutter::EncodableValue (" value" ),
195
+ flutter::EncodableValue (duration)}};
196
+ auto arguments = std::make_unique<flutter::EncodableValue>(wrapped);
197
+ channel->InvokeMethod (" audio.onDuration" , std::move (arguments));
198
+ };
190
199
191
200
SeekCompletedListener seek_completed_listener =
192
201
[channel = channel_.get ()](const std::string &player_id) {
@@ -200,24 +209,25 @@ class AudioplayersTizenPlugin : public flutter::Plugin {
200
209
201
210
UpdatePositionListener update_position_listener =
202
211
[channel = channel_.get ()](const std::string &player_id,
203
- const int duration, const int position) {
204
- flutter::EncodableMap durationWrapped = {
212
+ const int32_t duration,
213
+ const int32_t position) {
214
+ flutter::EncodableMap duration_wrapped = {
205
215
{flutter::EncodableValue (" playerId" ),
206
216
flutter::EncodableValue (player_id)},
207
217
{flutter::EncodableValue (" value" ),
208
218
flutter::EncodableValue (duration)}};
209
219
channel->InvokeMethod (
210
220
" audio.onDuration" ,
211
- std::make_unique<flutter::EncodableValue>(durationWrapped ));
221
+ std::make_unique<flutter::EncodableValue>(duration_wrapped ));
212
222
213
- flutter::EncodableMap positionWrapped = {
223
+ flutter::EncodableMap position_wrapped = {
214
224
{flutter::EncodableValue (" playerId" ),
215
225
flutter::EncodableValue (player_id)},
216
226
{flutter::EncodableValue (" value" ),
217
227
flutter::EncodableValue (position)}};
218
228
channel->InvokeMethod (
219
229
" audio.onCurrentPosition" ,
220
- std::make_unique<flutter::EncodableValue>(positionWrapped ));
230
+ std::make_unique<flutter::EncodableValue>(position_wrapped ));
221
231
};
222
232
223
233
PlayCompletedListener play_completed_listener =
0 commit comments