@@ -55,6 +55,7 @@ public class RhythmPlayer extends BaseFragment implements View.OnClickListener,
55
55
private boolean isPlaying = false ;
56
56
private SeekBar beatPerMinute , beatPerMeasure ;
57
57
private AgoraRhythmPlayerConfig agoraRhythmPlayerConfig = new AgoraRhythmPlayerConfig ();
58
+ private ChannelMediaOptions mChannelMediaOptions ;
58
59
59
60
@ Override
60
61
public void onCreate (@ Nullable Bundle savedInstanceState )
@@ -214,6 +215,10 @@ public void onClick(View v)
214
215
else if (v .getId () == R .id .play ){
215
216
if (!isPlaying ){
216
217
int ret = engine .startRhythmPlayer (URL_DOWNBEAT , URL_UPBEAT , agoraRhythmPlayerConfig );
218
+ if (joined ){
219
+ mChannelMediaOptions .publishRhythmPlayerTrack = true ;
220
+ engine .updateChannelMediaOptions (mChannelMediaOptions );
221
+ }
217
222
Log .i (TAG , "startRhythmPlayer result:" + ret );
218
223
isPlaying = true ;
219
224
beatPerMeasure .setEnabled (false );
@@ -222,6 +227,10 @@ else if(v.getId() == R.id.play){
222
227
}
223
228
else if (v .getId () == R .id .stop ){
224
229
engine .stopRhythmPlayer ();
230
+ if (joined ){
231
+ mChannelMediaOptions .publishRhythmPlayerTrack = false ;
232
+ engine .updateChannelMediaOptions (mChannelMediaOptions );
233
+ }
225
234
isPlaying = false ;
226
235
beatPerMeasure .setEnabled (true );
227
236
beatPerMinute .setEnabled (true );
@@ -246,15 +255,15 @@ private void joinChannel(String channelId)
246
255
/** Allows a user to join a channel.
247
256
if you do not specify the uid, we will generate the uid for you*/
248
257
249
- ChannelMediaOptions option = new ChannelMediaOptions ();
250
- option .autoSubscribeAudio = true ;
251
- option .autoSubscribeVideo = true ;
252
- option .publishMicrophoneTrack = true ;
258
+ mChannelMediaOptions = new ChannelMediaOptions ();
259
+ mChannelMediaOptions .autoSubscribeAudio = true ;
260
+ mChannelMediaOptions .autoSubscribeVideo = true ;
261
+ mChannelMediaOptions .publishMicrophoneTrack = true ;
253
262
/**
254
263
* config this for whether need push rhythem player to remote
255
264
*/
256
- option .publishRhythmPlayerTrack = true ;
257
- int res = engine .joinChannel (accessToken , channelId , 0 , option );
265
+ mChannelMediaOptions .publishRhythmPlayerTrack = isPlaying ;
266
+ int res = engine .joinChannel (accessToken , channelId , 0 , mChannelMediaOptions );
258
267
if (res != 0 ) {
259
268
// Usually happens with invalid parameters
260
269
// Error code description can be found at:
0 commit comments