Skip to content

Commit

Permalink
feat: add example for playEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Feb 10, 2021
1 parent 714024f commit 7987121
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 8 deletions.
Binary file not shown.
File renamed without changes.
12 changes: 12 additions & 0 deletions example/ios/AgoraExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
20F357B024636CDF00C146DC /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20F357AF24636CDF00C146DC /* File.swift */; };
F5A97F0625D3B42C00263532 /* Sound_Horizon.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = F5A97ED425D3ADDC00263532 /* Sound_Horizon.mp3 */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -31,6 +32,7 @@
871719007ECC5EAD276C345C /* Pods-AgoraExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AgoraExample.debug.xcconfig"; path = "Target Support Files/Pods-AgoraExample/Pods-AgoraExample.debug.xcconfig"; sourceTree = "<group>"; };
BCEA90A70F4BEAD7E9FA28B2 /* libPods-AgoraExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AgoraExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
F5A97ED425D3ADDC00263532 /* Sound_Horizon.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = Sound_Horizon.mp3; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -93,6 +95,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */,
83CBBA001A601CBA00E9B192 /* Products */,
2D16E6871FA4F8E400B85C8A /* Frameworks */,
F5A97ED525D3ADEF00263532 /* Resources */,
1CFFDEF7170271C97B8B7E5A /* Pods */,
20F357AD24636CDE00C146DC /* AgoraExample-Bridging-Header.h */,
);
Expand All @@ -109,6 +112,14 @@
name = Products;
sourceTree = "<group>";
};
F5A97ED525D3ADEF00263532 /* Resources */ = {
isa = PBXGroup;
children = (
F5A97ED425D3ADDC00263532 /* Sound_Horizon.mp3 */,
);
path = Resources;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -173,6 +184,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F5A97F0625D3B42C00263532 /* Sound_Horizon.mp3 in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction>
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForRunning = "YES">
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BuildableName = "React"
Expand All @@ -14,11 +20,26 @@
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
Expand All @@ -28,4 +49,18 @@
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Binary file added example/ios/Resources/Sound_Horizon.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@react-navigation/stack": "^5.7.1",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "^1.7.0",
"react-native-reanimated": "^1.10.1",
"react-native-safe-area-context": "^3.1.1",
Expand Down
50 changes: 46 additions & 4 deletions example/src/examples/basic/JoinChannelAudio.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { Component } from 'react';
import {
View,
TextInput,
PermissionsAndroid,
StyleSheet,
Button,
PermissionsAndroid,
Platform,
StyleSheet,
TextInput,
View,
} from 'react-native';

import RtcEngine, {
Expand All @@ -14,13 +14,16 @@ import RtcEngine, {
RtcEngineConfig,
} from 'react-native-agora';

import RNFS from 'react-native-fs';

const config = require('../../../agora.config.json');

interface State {
channelId: string;
isJoined: boolean;
openMicrophone: boolean;
enableSpeakerphone: boolean;
playEffect: boolean;
}

export default class JoinChannelAudio extends Component<{}, State, any> {
Expand All @@ -33,6 +36,7 @@ export default class JoinChannelAudio extends Component<{}, State, any> {
isJoined: false,
openMicrophone: true,
enableSpeakerphone: true,
playEffect: false,
};
}

Expand Down Expand Up @@ -108,12 +112,46 @@ export default class JoinChannelAudio extends Component<{}, State, any> {
});
};

_switchEffect = () => {
const { playEffect } = this.state;
if (playEffect) {
this._engine
?.stopEffect(1)
.then(() => {
this.setState({ playEffect: false });
})
.catch((err) => {
console.warn('stopEffect', err);
});
} else {
this._engine
?.playEffect(
1,
Platform.OS === 'ios'
? `${RNFS.MainBundlePath}/Sound_Horizon.mp3`
: '/assets/Sound_Horizon.mp3',
-1,
1,
1,
100,
true
)
.then(() => {
this.setState({ playEffect: true });
})
.catch((err) => {
console.warn('playEffect', err);
});
}
};

render() {
const {
channelId,
isJoined,
openMicrophone,
enableSpeakerphone,
playEffect,
} = this.state;
return (
<View style={styles.container}>
Expand All @@ -138,6 +176,10 @@ export default class JoinChannelAudio extends Component<{}, State, any> {
onPress={this._switchSpeakerphone}
title={enableSpeakerphone ? 'Speakerphone' : 'Earpiece'}
/>
<Button
onPress={this._switchEffect}
title={`${playEffect ? 'Stop' : 'Play'} effect`}
/>
</View>
</View>
);
Expand Down

0 comments on commit 7987121

Please sign in to comment.