add exaple sounds for native calls
This commit is contained in:
parent
db6b60d304
commit
218ac42d6e
@ -32,6 +32,10 @@
|
|||||||
84D0FEBE1E274DDD00EC3FE5 /* libSalmon Engine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C902A7815C5735700FBC901 /* libSalmon Engine.a */; };
|
84D0FEBE1E274DDD00EC3FE5 /* libSalmon Engine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C902A7815C5735700FBC901 /* libSalmon Engine.a */; };
|
||||||
84D0FEC91E274E4A00EC3FE5 /* libvorbis-tremor-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84D0FEC61E274E3700EC3FE5 /* libvorbis-tremor-ios.a */; };
|
84D0FEC91E274E4A00EC3FE5 /* libvorbis-tremor-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84D0FEC61E274E3700EC3FE5 /* libvorbis-tremor-ios.a */; };
|
||||||
84D0FECC1E274EBC00EC3FE5 /* main_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84D0FECA1E274EBC00EC3FE5 /* main_code.cpp */; };
|
84D0FECC1E274EBC00EC3FE5 /* main_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84D0FECA1E274EBC00EC3FE5 /* main_code.cpp */; };
|
||||||
|
AC67C87D211C8DD3003AA164 /* NativeSoundCalls.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC67C87C211C8DD3003AA164 /* NativeSoundCalls.swift */; };
|
||||||
|
AC67C87F211C8DE3003AA164 /* NativeSoundCallsImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC67C87E211C8DE3003AA164 /* NativeSoundCallsImpl.swift */; };
|
||||||
|
AC67C882211C8E24003AA164 /* gunshot_sound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = AC67C880211C8E24003AA164 /* gunshot_sound.mp3 */; };
|
||||||
|
AC67C883211C8E24003AA164 /* background_sound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = AC67C881211C8E24003AA164 /* background_sound.mp3 */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -103,6 +107,10 @@
|
|||||||
84D0FEC11E274E3700EC3FE5 /* vorbis-tremor-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "vorbis-tremor-ios.xcodeproj"; path = "../../libs/vorbis-tremor-ios/vorbis-tremor-ios.xcodeproj"; sourceTree = "<group>"; };
|
84D0FEC11E274E3700EC3FE5 /* vorbis-tremor-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "vorbis-tremor-ios.xcodeproj"; path = "../../libs/vorbis-tremor-ios/vorbis-tremor-ios.xcodeproj"; sourceTree = "<group>"; };
|
||||||
84D0FECA1E274EBC00EC3FE5 /* main_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_code.cpp; path = ../game/main_code.cpp; sourceTree = "<group>"; };
|
84D0FECA1E274EBC00EC3FE5 /* main_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_code.cpp; path = ../game/main_code.cpp; sourceTree = "<group>"; };
|
||||||
84D0FECB1E274EBC00EC3FE5 /* main_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_code.h; path = ../game/main_code.h; sourceTree = "<group>"; };
|
84D0FECB1E274EBC00EC3FE5 /* main_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_code.h; path = ../game/main_code.h; sourceTree = "<group>"; };
|
||||||
|
AC67C87C211C8DD3003AA164 /* NativeSoundCalls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeSoundCalls.swift; sourceTree = "<group>"; };
|
||||||
|
AC67C87E211C8DE3003AA164 /* NativeSoundCallsImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeSoundCallsImpl.swift; sourceTree = "<group>"; };
|
||||||
|
AC67C880211C8E24003AA164 /* gunshot_sound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = gunshot_sound.mp3; sourceTree = "<group>"; };
|
||||||
|
AC67C881211C8E24003AA164 /* background_sound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = background_sound.mp3; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -128,6 +136,8 @@
|
|||||||
4C49B2AE15B0991B003512CD = {
|
4C49B2AE15B0991B003512CD = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
AC67C881211C8E24003AA164 /* background_sound.mp3 */,
|
||||||
|
AC67C880211C8E24003AA164 /* gunshot_sound.mp3 */,
|
||||||
84D0FEC11E274E3700EC3FE5 /* vorbis-tremor-ios.xcodeproj */,
|
84D0FEC11E274E3700EC3FE5 /* vorbis-tremor-ios.xcodeproj */,
|
||||||
4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */,
|
4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */,
|
||||||
4C7B819515C40F770024D61A /* Libs */,
|
4C7B819515C40F770024D61A /* Libs */,
|
||||||
@ -217,6 +227,7 @@
|
|||||||
4CE6A9E315B2F9A4006A3965 /* Game */ = {
|
4CE6A9E315B2F9A4006A3965 /* Game */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
AC67C87B211C8DB6003AA164 /* sounds */,
|
||||||
74C3AE251E2E2A40003C07F2 /* creditscode.cpp */,
|
74C3AE251E2E2A40003C07F2 /* creditscode.cpp */,
|
||||||
74C3AE261E2E2A40003C07F2 /* creditscode.h */,
|
74C3AE261E2E2A40003C07F2 /* creditscode.h */,
|
||||||
74C3AE271E2E2A40003C07F2 /* game_area_interface.h */,
|
74C3AE271E2E2A40003C07F2 /* game_area_interface.h */,
|
||||||
@ -240,6 +251,15 @@
|
|||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
AC67C87B211C8DB6003AA164 /* sounds */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
AC67C87C211C8DD3003AA164 /* NativeSoundCalls.swift */,
|
||||||
|
AC67C87E211C8DE3003AA164 /* NativeSoundCallsImpl.swift */,
|
||||||
|
);
|
||||||
|
name = sounds;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@ -326,6 +346,8 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
AC67C882211C8E24003AA164 /* gunshot_sound.mp3 in Resources */,
|
||||||
|
AC67C883211C8E24003AA164 /* background_sound.mp3 in Resources */,
|
||||||
841270C91E639C2F00776DAE /* Images.xcassets in Resources */,
|
841270C91E639C2F00776DAE /* Images.xcassets in Resources */,
|
||||||
841D49651E65981600C85722 /* LaunchScreen.storyboard in Resources */,
|
841D49651E65981600C85722 /* LaunchScreen.storyboard in Resources */,
|
||||||
4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */,
|
4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */,
|
||||||
@ -345,12 +367,14 @@
|
|||||||
74EEBAEF1E2D13A6004C6C65 /* AppDelegate.swift in Sources */,
|
74EEBAEF1E2D13A6004C6C65 /* AppDelegate.swift in Sources */,
|
||||||
74C3AE2E1E2E2A40003C07F2 /* creditscode.cpp in Sources */,
|
74C3AE2E1E2E2A40003C07F2 /* creditscode.cpp in Sources */,
|
||||||
74C3AE2F1E2E2A40003C07F2 /* gamecode.cpp in Sources */,
|
74C3AE2F1E2E2A40003C07F2 /* gamecode.cpp in Sources */,
|
||||||
|
AC67C87D211C8DD3003AA164 /* NativeSoundCalls.swift in Sources */,
|
||||||
74EEBAF11E2D1C7C004C6C65 /* CustomGLKView.swift in Sources */,
|
74EEBAF11E2D1C7C004C6C65 /* CustomGLKView.swift in Sources */,
|
||||||
84D0FECC1E274EBC00EC3FE5 /* main_code.cpp in Sources */,
|
84D0FECC1E274EBC00EC3FE5 /* main_code.cpp in Sources */,
|
||||||
74C3AE301E2E2A40003C07F2 /* loadingcode.cpp in Sources */,
|
74C3AE301E2E2A40003C07F2 /* loadingcode.cpp in Sources */,
|
||||||
74AC9EBD1E2CE407003C9749 /* ViewController.swift in Sources */,
|
74AC9EBD1E2CE407003C9749 /* ViewController.swift in Sources */,
|
||||||
74AC9EC11E2CF533003C9749 /* SENamespaceWrapper.cpp in Sources */,
|
74AC9EC11E2CF533003C9749 /* SENamespaceWrapper.cpp in Sources */,
|
||||||
74C3AE311E2E2A40003C07F2 /* menucode.cpp in Sources */,
|
74C3AE311E2E2A40003C07F2 /* menucode.cpp in Sources */,
|
||||||
|
AC67C87F211C8DE3003AA164 /* NativeSoundCallsImpl.swift in Sources */,
|
||||||
4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */,
|
4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
11
proj.ios/NativeSoundCalls.swift
Normal file
11
proj.ios/NativeSoundCalls.swift
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol NativeSoundCalls {
|
||||||
|
|
||||||
|
func playBackgroundSound()
|
||||||
|
func stopBackgroundSound()
|
||||||
|
|
||||||
|
func playGunshotSound()
|
||||||
|
func stopGunshotSound()
|
||||||
|
|
||||||
|
}
|
54
proj.ios/NativeSoundCallsImpl.swift
Normal file
54
proj.ios/NativeSoundCallsImpl.swift
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import Foundation
|
||||||
|
import AVFoundation
|
||||||
|
|
||||||
|
// example sounds for native calls
|
||||||
|
// Created by Artem Budarin on 08.08.2018.
|
||||||
|
|
||||||
|
public class NativeSoundCallsImpl : NativeSoundCalls {
|
||||||
|
|
||||||
|
var backgroundPlayer: AVAudioPlayer?
|
||||||
|
var gunshotPlayer: AVAudioPlayer?
|
||||||
|
|
||||||
|
func playBackgroundSound() {
|
||||||
|
guard let url = Bundle.main.url(forResource: "background_sound", withExtension: "mp3") else { return }
|
||||||
|
do {
|
||||||
|
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
|
||||||
|
try AVAudioSession.sharedInstance().setActive(true)
|
||||||
|
backgroundPlayer = try AVAudioPlayer(contentsOf: url)
|
||||||
|
|
||||||
|
//swift 4
|
||||||
|
//backgroundPlayer = try AVAudioPlayer(contentsOf: url, fileTypeHint: AVFileType.mp3.rawValue)
|
||||||
|
|
||||||
|
backgroundPlayer?.numberOfLoops = NSInteger.max
|
||||||
|
backgroundPlayer?.play()
|
||||||
|
} catch let error {
|
||||||
|
print(error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopBackgroundSound() {
|
||||||
|
backgroundPlayer?.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func playGunshotSound() {
|
||||||
|
guard let url = Bundle.main.url(forResource: "gunshot_sound", withExtension: "mp3") else { return }
|
||||||
|
do {
|
||||||
|
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
|
||||||
|
try AVAudioSession.sharedInstance().setActive(true)
|
||||||
|
gunshotPlayer = try AVAudioPlayer(contentsOf: url)
|
||||||
|
|
||||||
|
//swift 4
|
||||||
|
//gunshotPlayer = try AVAudioPlayer(contentsOf: url, fileTypeHint: AVFileType.mp3.rawValue)
|
||||||
|
|
||||||
|
gunshotPlayer?.play()
|
||||||
|
} catch let error {
|
||||||
|
print(error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopGunshotSound() {
|
||||||
|
gunshotPlayer?.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
BIN
proj.ios/background_sound.mp3
Executable file
BIN
proj.ios/background_sound.mp3
Executable file
Binary file not shown.
BIN
proj.ios/gunshot_sound.mp3
Executable file
BIN
proj.ios/gunshot_sound.mp3
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user