Skip to content

Instantly share code, notes, and snippets.

@i-am-the-slime
Created June 22, 2013 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i-am-the-slime/fc207e61d50e29fe2837 to your computer and use it in GitHub Desktop.
Save i-am-the-slime/fc207e61d50e29fe2837 to your computer and use it in GitHub Desktop.
Where do I add: sound.play(compile in Compile, Sounds.Basso) ?
import sbt._
import Keys._
import sbtandroid._
import sbtandroid.AndroidKeys._
object General {
val settings = Defaults.defaultSettings ++ Seq (
name := "Nyx",
version := "0.1",
versionCode := 0,
scalaVersion := "2.10.1",
platformName in Android := "android-17"
)
val proguardSettings = Seq (
useProguard in Android := true,
proguardOption in Android := """
-keep class scala.Function1
-keep class scala.collection.SeqLike { public protected *; }
"""
)
lazy val fullAndroidSettings =
General.settings ++
AndroidProject.androidSettings ++
TypedResources.settings ++
proguardSettings ++
AndroidManifestGenerator.settings ++
AndroidMarketPublish.settings ++ Seq (
keyalias in Android := "change-me",
libraryDependencies += "com.squareup" % "otto" % "1.3.3",
libraryDependencies += "org.scaloid" %% "scaloid" % "2.0-8"
// libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"
// ,libraryDependencies += "org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"
)
}
object AndroidBuild extends Build {
lazy val main = Project (
"Nyx",
file("."),
settings = General.fullAndroidSettings
)
lazy val tests = Project (
"tests",
file("tests"),
settings = General.settings ++
AndroidTest.androidSettings ++
General.proguardSettings ++ Seq (
name := "NyxTests"
)
) dependsOn main
}
@orrsella
Copy link

Add to your plugins.sbt:

addSbtPlugin("com.orrsella" % "sbt-sound" % "1.0.1")

Then you can add it to the General object under settings (for example):

...
import com.orrsella.sbtsound.SbtSound._

object General {
  val settings = Defaults.defaultSettings ++ Seq (
    name := "Nyx",
    version := "0.1",
    versionCode := 0,
    scalaVersion := "2.10.1",
    platformName in Android := "android-17",
    sound.play(compile in Compile, Sounds.Basso)
  )
  ...
}

To configure which sounds play when see Configuration.

Hope this helps – let me know if you need more help.

Cheers,
Orr

@i-am-the-slime
Copy link
Author

...
  lazy val fullAndroidSettings =
    General.settings ++
    AndroidProject.androidSettings ++
    TypedResources.settings ++
    proguardSettings ++
    AndroidManifestGenerator.settings ++
    AndroidMarketPublish.settings ++ Seq (
      keyalias in Android := "change-me",
      libraryDependencies += "com.squareup" % "otto" % "1.3.3",
      libraryDependencies += "org.scaloid" %% "scaloid" % "2.0-8"
//      libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"
//    ,libraryDependencies += "org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"
    ) ++
    sound.play(installDevice in AndroidKeys.Android, "/Users/mark/Documents/Quatsch/Hoo.wav")
}
...

After quite a while of brute forcing I found how to play a sound when everything is done in Android. You might want to add this to the README. It could be of quite some help if any of the other 3 scala+android developers wants to use your plugin as well.

All the best,
Mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment