Skip to content

Commit 8eb67de

Browse files
author
Xia Ning
committed
fix mediaplayer sample layout issue.
use sdk 3.30 and mediaplyer 1.2.2 in gradle config
1 parent d391ec8 commit 8eb67de

3 files changed

Lines changed: 69 additions & 32 deletions

File tree

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaPlayerKit.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class MediaPlayerKit extends BaseFragment implements View.OnClickListener
6868

6969
private AgoraMediaPlayerKit agoraMediaPlayerKit;
7070
private boolean joined = false;
71-
private SeekBar progressBar;
71+
private SeekBar progressBar, volumeBar;
7272
private long playerDuration = 0;
7373

7474
private static final String SAMPLE_MOVIE_URL = "https://webdemo.agora.io/agora-web-showcase/examples/Agora-Custom-VideoSource-Web/assets/sample.mp4";
@@ -114,7 +114,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
114114
pause = view.findViewById(R.id.pause);
115115
publish = view.findViewById(R.id.publish);
116116
unpublish = view.findViewById(R.id.unpublish);
117-
118117
progressBar = view.findViewById(R.id.ctrl_progress_bar);
119118
progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
120119
@Override
@@ -133,6 +132,24 @@ public void onStopTrackingTouch(SeekBar seekBar) {
133132
}
134133

135134
});
135+
volumeBar = view.findViewById(R.id.ctrl_volume_bar);
136+
volumeBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
137+
@Override
138+
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
139+
agoraMediaPlayerKit.adjustPlayoutVolume(i);
140+
rtcChannelPublishHelper.adjustPublishSignalVolume(i,i);
141+
}
142+
143+
@Override
144+
public void onStartTrackingTouch(SeekBar seekBar) {
145+
146+
}
147+
148+
@Override
149+
public void onStopTrackingTouch(SeekBar seekBar) {
150+
151+
}
152+
});
136153
et_channel = view.findViewById(R.id.et_channel);
137154
et_url = view.findViewById(R.id.link);
138155
et_url.setText(SAMPLE_MOVIE_URL);
@@ -182,6 +199,11 @@ public void onMetaData(Constants.MediaPlayerMetadataType mediaPlayerMetadataType
182199

183200
}
184201

202+
@Override
203+
public void onPlayBufferUpdated(long l) {
204+
205+
}
206+
185207
@Override
186208
public void onPlayerEvent(Constants.MediaPlayerEvent eventCode) {
187209
LogUtil.i("agoraMediaPlayerKit1 onEvent:" + eventCode);
@@ -258,6 +280,9 @@ public void onClick(View v) {
258280
String url = et_url.getText().toString();
259281
if (url != null && !"".equals(url)) {
260282
agoraMediaPlayerKit.open(url, 0);
283+
progressBar.setVisibility(View.VISIBLE);
284+
volumeBar.setVisibility(View.VISIBLE);
285+
volumeBar.setProgress(100);
261286
}
262287
} else if (v.getId() == R.id.play) {
263288
agoraMediaPlayerKit.play();

Android/APIExample/app/src/main/res/layout/fragment_media_player_kit.xml

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,58 @@
55
android:layout_height="match_parent"
66
tools:context=".examples.advanced.MediaPlayerKit">
77

8-
<LinearLayout
9-
android:id="@+id/video_container"
8+
<FrameLayout
109
android:layout_width="match_parent"
11-
android:layout_height="match_parent"
12-
android:layout_alignParentTop="true"
13-
android:layout_marginBottom="186dp"
14-
android:orientation="vertical">
10+
android:layout_height="match_parent">
1511

16-
<FrameLayout
17-
android:id="@+id/fl_local"
18-
android:layout_weight="1.0"
12+
<LinearLayout
13+
android:id="@+id/video_container"
14+
android:layout_width="match_parent"
15+
android:layout_height="match_parent"
16+
android:layout_marginBottom="186dp"
17+
android:orientation="vertical">
18+
19+
<FrameLayout
20+
android:id="@+id/fl_local"
21+
android:layout_weight="0.5"
22+
android:layout_width="match_parent"
23+
android:layout_height="0dp" />
24+
25+
<FrameLayout
26+
android:id="@+id/fl_remote"
27+
android:layout_marginTop="1dp"
28+
android:layout_weight="0.5"
29+
android:layout_width="match_parent"
30+
android:layout_height="0dp" />
31+
</LinearLayout>
32+
33+
<SeekBar
34+
android:id="@+id/ctrl_progress_bar"
35+
android:visibility="invisible"
1936
android:layout_width="match_parent"
20-
android:layout_height="wrap_content" />
37+
android:layout_height="wrap_content"
38+
android:layout_marginTop="220dp"
39+
android:layout_marginStart="16dp"
40+
android:layout_marginEnd="16dp" />
2141

22-
<FrameLayout
23-
android:id="@+id/fl_remote"
24-
android:layout_marginTop="1dp"
25-
android:layout_weight="1.0"
42+
<SeekBar
43+
android:id="@+id/ctrl_volume_bar"
44+
android:visibility="invisible"
2645
android:layout_width="match_parent"
27-
android:layout_height="wrap_content" />
28-
</LinearLayout>
46+
android:layout_height="wrap_content"
47+
android:layout_marginTop="30dp"
48+
android:layout_marginStart="280dp"
49+
android:layout_marginEnd="16dp" />
2950

3051

52+
</FrameLayout>
3153

3254
<LinearLayout
3355
android:id="@+id/player_controller"
3456
android:layout_width="match_parent"
3557
android:layout_height="wrap_content"
36-
android:layout_alignBottom="@id/ctrl_progress_bar"
37-
android:layout_marginBottom="30dp"
58+
android:layout_alignBottom="@id/link_box"
59+
android:layout_marginBottom="40dp"
3860
android:gravity="center_vertical"
3961
android:orientation="horizontal">
4062

@@ -89,16 +111,6 @@
89111

90112

91113
</LinearLayout>
92-
93-
<SeekBar
94-
android:id="@+id/ctrl_progress_bar"
95-
android:layout_width="match_parent"
96-
android:layout_height="wrap_content"
97-
android:layout_marginBottom="50dp"
98-
android:layout_marginStart="16dp"
99-
android:layout_marginEnd="16dp"
100-
android:layout_alignBottom="@id/link_box" />
101-
102114
<LinearLayout
103115
android:id="@+id/link_box"
104116
android:layout_width="match_parent"

Android/APIExample/lib-component/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
// api 'io.agora.rtc:full-sdk:3.0.0'
3636
// api 'io.agora.rtc:full-sdk:3.1.2'
3737

38-
api 'io.agora.rtc:full-sdk:3.2.1'
39-
api 'io.agora:agoraplayer:1.1.2'
38+
api 'io.agora.rtc:full-sdk:3.3.0'
39+
api 'io.agora:agoraplayer:1.2.2'
4040

4141
}

0 commit comments

Comments
 (0)