Skip to content

Commit 562cb4a

Browse files
author
xia ning
authored
Merge branch 'master' into dev/3.5.1
2 parents a4fdaa2 + 6501f4c commit 562cb4a

14 files changed

Lines changed: 65 additions & 76 deletions

File tree

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,14 @@ else if (v.getId() == R.id.btn_effect)
323323
}
324324

325325
private void stopProgressTimer() {
326-
mixingProgressBar.setProgress(0);
327326
handler.removeCallbacksAndMessages(null);
328327
}
329328

330329
private void startProgressTimer() {
331-
if(engine != null) {
332-
int currentPosition = engine.getAudioMixingCurrentPosition();
333-
if (mixingProgressBar.getMax() != 0 && !mixingProgressBar.isPressed())
334-
mixingProgressBar.setProgress(currentPosition);
335-
handler.postDelayed(this::startProgressTimer, 1000);
336-
}
330+
final int result = (int) ((float) engine.getAudioMixingCurrentPosition() / (float) engine.getAudioMixingDuration(Constant.MIX_FILE_PATH) * 100);
331+
mixingProgressBar.setProgress(Long.valueOf(result).intValue());
332+
handler.postDelayed(this::startProgressTimer, 500);
337333
}
338-
339334
/**
340335
* @param channelId Specify the channel name that you want to join.
341336
* Users that input the same channel name join the same channel.*/

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

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
public class SwitchExternalVideo extends BaseFragment implements View.OnClickListener {
6969
private static final String TAG = SwitchExternalVideo.class.getSimpleName();
7070

71-
private FrameLayout fl_remote;
7271
private RelativeLayout fl_local;
7372
private Button join, localVideo;
7473
private EditText et_channel;
@@ -101,7 +100,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
101100
join = view.findViewById(R.id.btn_join);
102101
localVideo = view.findViewById(R.id.localVideo);
103102
et_channel = view.findViewById(R.id.et_channel);
104-
fl_remote = view.findViewById(R.id.fl_remote);
105103
fl_local = view.findViewById(R.id.fl_local);
106104
join.setOnClickListener(this);
107105
localVideo.setOnClickListener(this);
@@ -193,7 +191,6 @@ public void onClick(View v) {
193191
joined = false;
194192
join.setText(getString(R.string.join));
195193
localVideo.setEnabled(false);
196-
fl_remote.removeAllViews();
197194
fl_local.removeAllViews();
198195
/**After joining a channel, the user must call the leaveChannel method to end the
199196
* call before joining another channel. This method returns 0 if the user leaves the
@@ -417,26 +414,26 @@ public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
417414
public void onRemoteVideoStateChanged(int uid, int state, int reason, int elapsed) {
418415
super.onRemoteVideoStateChanged(uid, state, reason, elapsed);
419416
Log.i(TAG, "onRemoteVideoStateChanged:uid->" + uid + ", state->" + state);
420-
if (state == REMOTE_VIDEO_STATE_STARTING) {
421-
/**Check if the context is correct*/
422-
Context context = getContext();
423-
if (context == null) {
424-
return;
425-
}
426-
handler.post(() ->
427-
{
428-
/**Display remote video stream*/
429-
SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
430-
surfaceView.setZOrderMediaOverlay(true);
431-
if (fl_remote.getChildCount() > 0) {
432-
fl_remote.removeAllViews();
433-
}
434-
fl_remote.addView(surfaceView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
435-
ViewGroup.LayoutParams.MATCH_PARENT));
436-
/**Setup remote video to render*/
437-
ENGINE.setupRemoteVideo(new VideoCanvas(surfaceView, RENDER_MODE_HIDDEN, uid));
438-
});
439-
}
417+
// if (state == REMOTE_VIDEO_STATE_STARTING) {
418+
// /**Check if the context is correct*/
419+
// Context context = getContext();
420+
// if (context == null) {
421+
// return;
422+
// }
423+
// handler.post(() ->
424+
// {
425+
// /**Display remote video stream*/
426+
// SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
427+
// surfaceView.setZOrderMediaOverlay(true);
428+
// if (fl_remote.getChildCount() > 0) {
429+
// fl_remote.removeAllViews();
430+
// }
431+
// fl_remote.addView(surfaceView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
432+
// ViewGroup.LayoutParams.MATCH_PARENT));
433+
// /**Setup remote video to render*/
434+
// ENGINE.setupRemoteVideo(new VideoCanvas(surfaceView, RENDER_MODE_HIDDEN, uid));
435+
// });
436+
// }
440437
}
441438

442439
/**Occurs when a remote user (Communication)/host (Live Broadcast) joins the channel.
@@ -463,17 +460,17 @@ public void onUserJoined(int uid, int elapsed) {
463460
@Override
464461
public void onUserOffline(int uid, int reason) {
465462
Log.i(TAG, String.format("user %d offline! reason:%d", uid, reason));
466-
showLongToast(String.format("user %d offline! reason:%d", uid, reason));
467-
handler.post(new Runnable() {
468-
@Override
469-
public void run() {
470-
/**Clear render view
471-
Note: The video will stay at its last frame, to completely remove it you will need to
472-
remove the SurfaceView from its parent*/
473-
ENGINE.setupRemoteVideo(new VideoCanvas(null, RENDER_MODE_HIDDEN, uid));
474-
fl_remote.removeAllViews();
475-
}
476-
});
463+
// showLongToast(String.format("user %d offline! reason:%d", uid, reason));
464+
// handler.post(new Runnable() {
465+
// @Override
466+
// public void run() {
467+
// /**Clear render view
468+
// Note: The video will stay at its last frame, to completely remove it you will need to
469+
// remove the SurfaceView from its parent*/
470+
// ENGINE.setupRemoteVideo(new VideoCanvas(null, RENDER_MODE_HIDDEN, uid));
471+
// fl_remote.removeAllViews();
472+
// }
473+
// });
477474
}
478475
};
479476

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
android:layout_height="match_parent"
1313
android:layout_above="@+id/ll_join" />
1414

15-
<FrameLayout
16-
android:id="@+id/fl_remote"
17-
android:layout_alignParentEnd="true"
18-
android:layout_width="180dp"
19-
android:layout_height="240dp"/>
20-
2115
<LinearLayout
2216
android:id="@+id/ll_join"
2317
android:layout_width="match_parent"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ If you have any problems or suggestions regarding the sample projects, feel free
2929

3030
## License
3131

32-
The sample projects are under the MIT license. See the [LICENSE](./LICENSE) file for details.
32+
The sample projects are under the MIT license.

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030

3131
## 许可证
3232

33-
示例项目遵守 MIT 许可证。详见 [LICENSE](./LICENSE) 文件。
33+
示例项目遵守 MIT 许可证。

iOS/APIExample/Common/KeyCenter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
struct KeyCenter {
1010
static let AppId: String = <#Your App Id#>
11-
11+
1212
// assign token to nil if you have not enabled app certificate
1313
static var Token: String? = <#Temp Access Token#>
1414
}

macOS/APIExample/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ extension MenuController: NSTableViewDataSource, NSTableViewDelegate {
108108
}
109109

110110
func tableViewSelectionDidChange(_ notification: Notification) {
111-
if (tableView.selectedRow >= 0) {
111+
if tableView.selectedRow >= 0 && tableView.selectedRow < menus.count {
112112
loadSplitViewItem(item: menus[tableView.selectedRow])
113113
}
114114
}

windows/APIExample/APIExample.sln

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcessScreenShare", "APIEx
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Win32 = Debug|Win32
1213
Debug|x64 = Debug|x64
13-
Debug|x86 = Debug|x86
14+
Release|Win32 = Release|Win32
1415
Release|x64 = Release|x64
15-
Release|x86 = Release|x86
1616
EndGlobalSection
1717
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|Win32.ActiveCfg = Debug|Win32
19+
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|Win32.Build.0 = Debug|Win32
1820
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x64.ActiveCfg = Debug|x64
1921
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x64.Build.0 = Debug|x64
20-
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x86.ActiveCfg = Debug|Win32
21-
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x86.Build.0 = Debug|Win32
22+
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|Win32.ActiveCfg = Release|Win32
23+
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|Win32.Build.0 = Release|Win32
2224
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x64.ActiveCfg = Release|x64
2325
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x64.Build.0 = Release|x64
24-
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x86.ActiveCfg = Release|Win32
25-
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x86.Build.0 = Release|Win32
26+
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|Win32.ActiveCfg = Debug|Win32
27+
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|Win32.Build.0 = Debug|Win32
2628
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|x64.ActiveCfg = Debug|Win32
27-
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|x86.ActiveCfg = Debug|Win32
28-
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|x86.Build.0 = Debug|Win32
29+
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|Win32.ActiveCfg = Release|Win32
30+
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|Win32.Build.0 = Release|Win32
2931
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|x64.ActiveCfg = Release|Win32
30-
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|x86.ActiveCfg = Release|Win32
31-
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|x86.Build.0 = Release|Win32
3232
EndGlobalSection
3333
GlobalSection(SolutionProperties) = preSolution
3434
HideSolutionNode = FALSE

windows/APIExample/APIExample/APIExample.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\A
129129
<ManifestResourceCompile>
130130
<ResourceOutputFileName>$(IntDir)$(TargetName)$(TargetExt).embed.manifest.res</ResourceOutputFileName>
131131
</ManifestResourceCompile>
132+
<PreBuildEvent>
133+
<Command>$(SolutionDir)installThirdParty.bat</Command>
134+
</PreBuildEvent>
132135
</ItemDefinitionGroup>
133136
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
134137
<ClCompile>

windows/APIExample/APIExample/d3d/D3DRender.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,11 @@ int D3DRender::Init(HWND hwnd, unsigned int nWidth, unsigned int nHeight, bool i
3636
if (FAILED(lRet))
3737
return -1;
3838

39-
if (isYuv) {
40-
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, (D3DFORMAT)'21VY', D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
41-
if (FAILED(lRet))
42-
return -1;
43-
}
44-
else {
45-
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
46-
if (FAILED(lRet))
47-
return -1;
48-
}
49-
39+
D3DFORMAT format = isYuv ? (D3DFORMAT)'21VY' : D3DFMT_X8R8G8B8;
40+
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, format, D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
41+
if (FAILED(lRet))
42+
return -1;
43+
5044
m_nWidth = nWidth;
5145
m_nHeight = nHeight;
5246
m_bIsYuv = isYuv;

0 commit comments

Comments
 (0)