example/simple update sounds test
authorBlackMinou <romain.chanoir@viacesi.fr>
Wed, 3 Jun 2015 11:13:40 +0000 (13:13 +0200)
committerBlackMinou <romain.chanoir@viacesi.fr>
Tue, 9 Jun 2015 11:37:48 +0000 (13:37 +0200)
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

examples/mnit_simple/src/test_assets_and_resources.nit
examples/mnit_simple/src/test_audio.nit

index c4ffc7f..c63b556 100644 (file)
@@ -18,7 +18,7 @@
 module test_assets_and_resources
 
 import simple_android
-import android::assets_and_resources
+intrude import android::assets_and_resources
 
 redef class App
        redef fun input( ie )
@@ -33,7 +33,7 @@ redef class App
        # Testing the assets manager
        fun test_assets
        do
-               assert asset_manager.bitmap("fighter.png").width == 32
+               assert not asset_manager.open_fd("testsound.ogg").is_java_null
        end
 
        # Testing the resources manager
index cca7e1f..2a3a77b 100644 (file)
@@ -21,30 +21,50 @@ import simple_android
 import android::audio
 
 redef class App
-       var soundsp: nullable Sound
-       var soundmp: nullable Sound
+       # Sound
+       var soundsp: Sound
+       # Music
+       var soundmp: Music
+       # Sound
+       var easy_soundsp = new Sound("testsound")
+       # Music
+       var easy_soundmp = new Music("xylofon")
+       # testing from assets ?
        var test_assets = false
+       # testinf from resources ?
        var test_ressources = true
+       # testing the automatic way ?
+       var test_easy_sounds = false
 
        redef fun on_create
        do
                super
+               default_mediaplayer.looping = true
                if test_assets then
-                       soundsp = load_sound("testsound.ogg")
-                       soundmp = load_music("xylofon.ogg")
+                       soundsp = load_sound("testsound.og")
+                       soundmp = load_music("xylofon.og")
+                       soundmp.play
                end
                if test_ressources then
                        soundsp = load_sound_from_res("testsound")
                        soundmp = load_music_from_res("xylofon")
+                       soundmp.play
+               end
+               if test_easy_sounds then
+                       easy_soundsp.load
+                       easy_soundmp.load
+                       easy_soundmp.play
                end
-               default_mediaplayer.looping = true
-               soundmp.play
        end
 
        redef fun input( ie )
        do
                if ie isa PointerEvent and ie.depressed then
-                       soundsp.play
+                       if test_assets or test_ressources then
+                               soundsp.play
+                       else if test_easy_sounds then
+                               easy_soundsp.play
+                       end
                end
                return super
        end