diff --git a/nirvana-ios.xcodeproj/project.pbxproj b/nirvana-ios.xcodeproj/project.pbxproj index c540f14..b6152cb 100644 --- a/nirvana-ios.xcodeproj/project.pbxproj +++ b/nirvana-ios.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 89091993277D958D0025F4BB /* ConvoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89091992277D958D0025F4BB /* ConvoViewModel.swift */; }; 89091995277DD9F80025F4BB /* ConvoFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89091994277DD9F80025F4BB /* ConvoFooterView.swift */; }; 89091997277DDE030025F4BB /* ProfilePicturesOverlappedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89091996277DDE030025F4BB /* ProfilePicturesOverlappedView.swift */; }; + 89091999277EFDCC0025F4BB /* leaveSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 89091998277EFDCC0025F4BB /* leaveSound.mp3 */; }; + 8909199C277EFDF30025F4BB /* joinSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 8909199B277EFDF30025F4BB /* joinSound.mp3 */; }; 890C245D277BF628009B4A30 /* AgoraRtcKit in Frameworks */ = {isa = PBXBuildFile; productRef = 890C245C277BF628009B4A30 /* AgoraRtcKit */; }; 890C2460277BF896009B4A30 /* AgoraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C245F277BF896009B4A30 /* AgoraViewController.swift */; }; 890C2462277BF935009B4A30 /* CallView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C2461277BF935009B4A30 /* CallView.swift */; }; @@ -98,6 +100,8 @@ 89091992277D958D0025F4BB /* ConvoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvoViewModel.swift; sourceTree = ""; }; 89091994277DD9F80025F4BB /* ConvoFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvoFooterView.swift; sourceTree = ""; }; 89091996277DDE030025F4BB /* ProfilePicturesOverlappedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilePicturesOverlappedView.swift; sourceTree = ""; }; + 89091998277EFDCC0025F4BB /* leaveSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = leaveSound.mp3; sourceTree = ""; }; + 8909199B277EFDF30025F4BB /* joinSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = joinSound.mp3; sourceTree = ""; }; 890C245F277BF896009B4A30 /* AgoraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraViewController.swift; sourceTree = ""; }; 890C2461277BF935009B4A30 /* CallView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallView.swift; sourceTree = ""; }; 890C2463277BFA97009B4A30 /* AgroRep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgroRep.swift; sourceTree = ""; }; @@ -194,6 +198,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 8909199A277EFDE50025F4BB /* sounds */ = { + isa = PBXGroup; + children = ( + 8909199B277EFDF30025F4BB /* joinSound.mp3 */, + 89091998277EFDCC0025F4BB /* leaveSound.mp3 */, + ); + path = sounds; + sourceTree = ""; + }; 890C245E277BF888009B4A30 /* VoiceCallTest */ = { isa = PBXGroup; children = ( @@ -231,6 +244,7 @@ 891A15DF27653A7000B26659 /* nirvana-ios */ = { isa = PBXGroup; children = ( + 8909199A277EFDE50025F4BB /* sounds */, 891060E527743FEB00F14509 /* nirvana-ios.entitlements */, 89AD557D276E01E2001658E0 /* Repositories */, 89F05BA2276ACBFA0002E9C7 /* Services */, @@ -587,7 +601,9 @@ files = ( 891A15F12765528700B26659 /* Satisfy-Regular.ttf in Resources */, 89A107E927753AB600B971FD /* GoogleService-Info.plist in Resources */, + 89091999277EFDCC0025F4BB /* leaveSound.mp3 in Resources */, 891A15E827653A7100B26659 /* Preview Assets.xcassets in Resources */, + 8909199C277EFDF30025F4BB /* joinSound.mp3 in Resources */, 891A15E527653A7100B26659 /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/nirvana-ios/Assets.xcassets/sounds/[5]__Notify__Sound.dataset/Contents.json b/nirvana-ios/Assets.xcassets/sounds/joinSound.dataset/Contents.json similarity index 72% rename from nirvana-ios/Assets.xcassets/sounds/[5]__Notify__Sound.dataset/Contents.json rename to nirvana-ios/Assets.xcassets/sounds/joinSound.dataset/Contents.json index 3c97b2b..58de6d7 100644 --- a/nirvana-ios/Assets.xcassets/sounds/[5]__Notify__Sound.dataset/Contents.json +++ b/nirvana-ios/Assets.xcassets/sounds/joinSound.dataset/Contents.json @@ -1,7 +1,7 @@ { "data" : [ { - "filename" : "[5]__Notify__Sound.mp3", + "filename" : "joinSound.mp3", "idiom" : "universal" } ], diff --git a/nirvana-ios/Assets.xcassets/sounds/[8]__Notify__Sound.dataset/[8]__Notify__Sound.mp3 b/nirvana-ios/Assets.xcassets/sounds/joinSound.dataset/joinSound.mp3 similarity index 100% rename from nirvana-ios/Assets.xcassets/sounds/[8]__Notify__Sound.dataset/[8]__Notify__Sound.mp3 rename to nirvana-ios/Assets.xcassets/sounds/joinSound.dataset/joinSound.mp3 diff --git a/nirvana-ios/Assets.xcassets/sounds/[8]__Notify__Sound.dataset/Contents.json b/nirvana-ios/Assets.xcassets/sounds/leaveSound.dataset/Contents.json similarity index 72% rename from nirvana-ios/Assets.xcassets/sounds/[8]__Notify__Sound.dataset/Contents.json rename to nirvana-ios/Assets.xcassets/sounds/leaveSound.dataset/Contents.json index 5b12314..8ec16f8 100644 --- a/nirvana-ios/Assets.xcassets/sounds/[8]__Notify__Sound.dataset/Contents.json +++ b/nirvana-ios/Assets.xcassets/sounds/leaveSound.dataset/Contents.json @@ -1,7 +1,7 @@ { "data" : [ { - "filename" : "[8]__Notify__Sound.mp3", + "filename" : "leaveSound.mp3", "idiom" : "universal" } ], diff --git a/nirvana-ios/Assets.xcassets/sounds/[5]__Notify__Sound.dataset/[5]__Notify__Sound.mp3 b/nirvana-ios/Assets.xcassets/sounds/leaveSound.dataset/leaveSound.mp3 similarity index 100% rename from nirvana-ios/Assets.xcassets/sounds/[5]__Notify__Sound.dataset/[5]__Notify__Sound.mp3 rename to nirvana-ios/Assets.xcassets/sounds/leaveSound.dataset/leaveSound.mp3 diff --git a/nirvana-ios/Views/Convos/ConvoFooterView.swift b/nirvana-ios/Views/Convos/ConvoFooterView.swift index 8474ce1..98b645b 100644 --- a/nirvana-ios/Views/Convos/ConvoFooterView.swift +++ b/nirvana-ios/Views/Convos/ConvoFooterView.swift @@ -81,7 +81,6 @@ struct ConvoFooterView: View { Button { print("disconnecting user now ") - self.convoVM.selectedConvoId = nil self.convoVM.leaveConvo() // show success or failure toast diff --git a/nirvana-ios/Views/Convos/ConvoViewModel.swift b/nirvana-ios/Views/Convos/ConvoViewModel.swift index 1c20916..8852075 100644 --- a/nirvana-ios/Views/Convos/ConvoViewModel.swift +++ b/nirvana-ios/Views/Convos/ConvoViewModel.swift @@ -87,7 +87,7 @@ class ConvoViewModel: NSObject, ObservableObject { } // TODO: if convo receiver is me, then join in - if convo!.receiverUserId == userId { + if convo!.receiverUserId == userId && !(self?.isInCall())! { self?.joinConvo(convo: convo!) } @@ -245,10 +245,12 @@ extension ConvoViewModel { } func playJoinAudioEffect(engine: AgoraRtcEngineKit) { + print("playing JOINED audio sound") + // Sets the audio effect ID. let EFFECT_ID:Int32 = 1 // Sets the path of the audio effect file. - let filePath = Bundle.main.path(forResource: "[8]__Notify__Sound", ofType: "mp3") + let filePath = Bundle.main.path(forResource: "joinSound", ofType: "mp3") // Sets the number of times the audio effect loops. -1 represents an infinite loop. let loopCount = 1 // Sets the pitch of the audio effect. The value range is 0.5 to 2.0, where 1.0 is the original pitch. @@ -259,7 +261,7 @@ extension ConvoViewModel { // Sets the volume of the audio effect. The value range is 0 to 100. 100 represents the original volume. let gain = 100.0 // Sets whether to publish the audio effect to the remote users. true represents that both the local user and remote users can hear the audio effect; false represents that only the local user can hear the audio effect. - let publish = true + let publish = false // Sets the playback position (ms) of the audio effect file. 500 represents that the playback starts at the 500 ms mark of the audio effect file. let startPos: Int32 = 500; // Plays the specified audio effect file. @@ -267,10 +269,12 @@ extension ConvoViewModel { } func playLeaveAudioEffect(engine: AgoraRtcEngineKit) { + print("playing LEFT audio sound") + // Sets the audio effect ID. let EFFECT_ID:Int32 = 2 // Sets the path of the audio effect file. - let filePath = Bundle.main.path(forResource: "[5]__Notify__Sound", ofType: "mp3") + let filePath = Bundle.main.path(forResource: "leaveSound", ofType: "mp3") // Sets the number of times the audio effect loops. -1 represents an infinite loop. let loopCount = 1 // Sets the pitch of the audio effect. The value range is 0.5 to 2.0, where 1.0 is the original pitch. @@ -281,7 +285,7 @@ extension ConvoViewModel { // Sets the volume of the audio effect. The value range is 0 to 100. 100 represents the original volume. let gain = 100.0 // Sets whether to publish the audio effect to the remote users. true represents that both the local user and remote users can hear the audio effect; false represents that only the local user can hear the audio effect. - let publish = true + let publish = false // Sets the playback position (ms) of the audio effect file. 500 represents that the playback starts at the 500 ms mark of the audio effect file. let startPos: Int32 = 500; // Plays the specified audio effect file. @@ -320,6 +324,8 @@ extension ConvoViewModel: AgoraRtcEngineDelegate { self?.firestoreService.updateConvo(convo: (self?.currConvo)!) {[weak self] res in print(res) + + } case .error(let error): print(error) @@ -378,10 +384,14 @@ extension ConvoViewModel: AgoraRtcEngineDelegate { func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinedOfUid uid: UInt, elapsed: Int) { print("new user joined \(uid)") + + self.playJoinAudioEffect(engine: engine) } func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: AgoraUserOfflineReason) { - print("user joined left") + print("a user left") + + self.playLeaveAudioEffect(engine: engine) } func rtcEngine(_ engine: AgoraRtcEngineKit, didOccurWarning warningCode: AgoraWarningCode) { diff --git a/nirvana-ios/Views/InnerCircle/CircleGridView.swift b/nirvana-ios/Views/InnerCircle/CircleGridView.swift index 39a282b..14bfcd2 100644 --- a/nirvana-ios/Views/InnerCircle/CircleGridView.swift +++ b/nirvana-ios/Views/InnerCircle/CircleGridView.swift @@ -331,7 +331,7 @@ struct CircleGridView: View { scrollReaderValue.scrollTo(self.selectedFriendIndex) } - self.animateLiveConvos = true + self.animateLiveConvos = true } } // scrollview reader } diff --git a/nirvana-ios/sounds/joinSound.mp3 b/nirvana-ios/sounds/joinSound.mp3 new file mode 100644 index 0000000..4a42d9b Binary files /dev/null and b/nirvana-ios/sounds/joinSound.mp3 differ diff --git a/nirvana-ios/sounds/leaveSound.mp3 b/nirvana-ios/sounds/leaveSound.mp3 new file mode 100644 index 0000000..ef17270 Binary files /dev/null and b/nirvana-ios/sounds/leaveSound.mp3 differ