diff --git a/android/app/build.gradle b/android/app/build.gradle index 7f7d22f..0bfa490 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -151,6 +151,7 @@ android { } dependencies { + implementation project(':react-native-sound') implementation project(':react-native-gesture-handler') implementation project(':react-native-linear-gradient') implementation fileTree(dir: "libs", include: ["*.jar"]) diff --git a/android/app/src/main/java/com/sortgame/MainApplication.java b/android/app/src/main/java/com/sortgame/MainApplication.java index da039fb..790ef8a 100644 --- a/android/app/src/main/java/com/sortgame/MainApplication.java +++ b/android/app/src/main/java/com/sortgame/MainApplication.java @@ -3,6 +3,7 @@ import android.app.Application; import com.facebook.react.ReactApplication; +import com.zmxv.RNSound.RNSoundPackage; import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; import com.BV.LinearGradient.LinearGradientPackage; import com.facebook.react.ReactNativeHost; @@ -25,6 +26,7 @@ public boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new RNSoundPackage(), new RNGestureHandlerPackage(), new LinearGradientPackage() ); diff --git a/android/app/src/main/res/raw/angry_cat.mp3 b/android/app/src/main/res/raw/angry_cat.mp3 new file mode 100644 index 0000000..32eb211 Binary files /dev/null and b/android/app/src/main/res/raw/angry_cat.mp3 differ diff --git a/android/settings.gradle b/android/settings.gradle index e4fc3fc..6825988 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'sortGame' +include ':react-native-sound' +project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android') include ':react-native-gesture-handler' project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android') include ':react-native-linear-gradient' diff --git a/ios/sortGame.xcodeproj/project.pbxproj b/ios/sortGame.xcodeproj/project.pbxproj index 43b6e65..aee445a 100644 --- a/ios/sortGame.xcodeproj/project.pbxproj +++ b/ios/sortGame.xcodeproj/project.pbxproj @@ -43,6 +43,7 @@ 011E034382EE43388A94E903 /* MavenPro-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B019264024354815B8C3C005 /* MavenPro-Regular.ttf */; }; F521CC3EB28D4678974A4914 /* libBVLinearGradient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D64C1B9E05E54689AF759AA9 /* libBVLinearGradient.a */; }; E91CC28BFFE843C6AEA5ED9F /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CA2C19306ED4E638864331B /* libRNGestureHandler.a */; }; + C0CB6B4AAF3747F1917B5A43 /* libRNSound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B5D7C906FE545EA8F107AA2 /* libRNSound.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -356,6 +357,8 @@ D64C1B9E05E54689AF759AA9 /* libBVLinearGradient.a */ = {isa = PBXFileReference; name = "libBVLinearGradient.a"; path = "libBVLinearGradient.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; 7880ED94D39E436EA8112CC1 /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; name = "RNGestureHandler.xcodeproj"; path = "../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 8CA2C19306ED4E638864331B /* libRNGestureHandler.a */ = {isa = PBXFileReference; name = "libRNGestureHandler.a"; path = "libRNGestureHandler.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; + 0A1DB073FD0E4D009653D3D8 /* RNSound.xcodeproj */ = {isa = PBXFileReference; name = "RNSound.xcodeproj"; path = "../node_modules/react-native-sound/RNSound.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 2B5D7C906FE545EA8F107AA2 /* libRNSound.a */ = {isa = PBXFileReference; name = "libRNSound.a"; path = "libRNSound.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -386,6 +389,7 @@ 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, F521CC3EB28D4678974A4914 /* libBVLinearGradient.a in Frameworks */, E91CC28BFFE843C6AEA5ED9F /* libRNGestureHandler.a in Frameworks */, + C0CB6B4AAF3747F1917B5A43 /* libRNSound.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -574,6 +578,7 @@ 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, DE8F1DC1A36E4985BC48BCF5 /* BVLinearGradient.xcodeproj */, 7880ED94D39E436EA8112CC1 /* RNGestureHandler.xcodeproj */, + 0A1DB073FD0E4D009653D3D8 /* RNSound.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -1217,11 +1222,13 @@ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sortGame.app/sortGame"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Debug; @@ -1242,11 +1249,13 @@ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sortGame.app/sortGame"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Release; @@ -1270,6 +1279,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Debug; @@ -1292,6 +1302,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Release; @@ -1321,11 +1332,13 @@ TVOS_DEPLOYMENT_TARGET = 9.2; LIBRARY_SEARCH_PATHS = ( "$(inherited)", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Debug; @@ -1355,11 +1368,13 @@ TVOS_DEPLOYMENT_TARGET = 9.2; LIBRARY_SEARCH_PATHS = ( "$(inherited)", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Release; @@ -1388,11 +1403,13 @@ TVOS_DEPLOYMENT_TARGET = 10.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Debug; @@ -1421,11 +1438,13 @@ TVOS_DEPLOYMENT_TARGET = 10.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", + "$(SRCROOT)/../node_modules/react-native-sound/RNSound", ); }; name = Release; diff --git a/package-lock.json b/package-lock.json index e09d06d..1908a79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11005,6 +11005,11 @@ "resolved": "https://registry.npmjs.org/react-native-screens/-/react-native-screens-1.0.0-alpha.22.tgz", "integrity": "sha512-kSyAt0AeVU6N7ZonfV6dP6iZF8B7Bce+tk3eujXhzBGsLg0VSLnU7uE9VqJF0xdQrHR91ZjGgVMieo/8df9KTA==" }, + "react-native-sound": { + "version": "0.10.12", + "resolved": "https://registry.npmjs.org/react-native-sound/-/react-native-sound-0.10.12.tgz", + "integrity": "sha512-lhvzZ+ekNSHW9s4FjmxxGAQmd7yDT9FnHgJNP824cMyHRrTES/LgHnSOxES/1FWVoaQ8FdfbEHkWd2rN0G/L9A==" + }, "react-native-tab-view": { "version": "0.0.77", "resolved": "https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-0.0.77.tgz", diff --git a/package.json b/package.json index 0eee363..dffb15b 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "react-native-linear-gradient": "^2.5.4", "react-native-material-menu": "^0.4.0", "react-native-popup-dialog": "^0.15.0", + "react-native-sound": "^0.10.12", "react-navigation": "^2.14.0", "react-redux": "^5.0.7", "recompose": "^0.29.0", diff --git a/src/components/Info.js b/src/components/Info.js index 7fc6e70..8ef12b2 100644 --- a/src/components/Info.js +++ b/src/components/Info.js @@ -133,6 +133,23 @@ const Info = ({scrollViewRef}) => { ); })} + + audio sources + + + "Cat, Screaming, A.wav" by InspectorJ (www.jshaw.co.uk) of Freesound.org + ); diff --git a/src/containers/GameScreen.js b/src/containers/GameScreen.js index 690d023..35ea04b 100644 --- a/src/containers/GameScreen.js +++ b/src/containers/GameScreen.js @@ -27,6 +27,7 @@ const getItemSize = makePhotoSourceSize(itemHeight); import {consoleTime, consoleTimeEnd} from "../utils/debugUtils"; import AppearOnMount from "../components/AppearOnMount"; +import {playFailureCat} from "../utils/music" type State = { rightAnswers: Array, @@ -100,6 +101,7 @@ class GameScreen extends React.Component<$FlowFixMeProps, State<*>> { } vibrateOnWrongAnswer = () => { + playFailureCat() Vibration.vibrate(200); }; diff --git a/src/utils/music.js b/src/utils/music.js new file mode 100644 index 0000000..2b22382 --- /dev/null +++ b/src/utils/music.js @@ -0,0 +1,9 @@ +const Sound = require('react-native-sound'); + +const FailureCat = new Sound('angry_cat.mp3', Sound.MAIN_BUNDLE, (error) => { + +}); + +export const playFailureCat = () => { + FailureCat.play(); +}