app::audio: drop the old load_sound and load_music
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 28 Aug 2016 13:01:17 +0000 (09:01 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sun, 28 Aug 2016 13:59:06 +0000 (09:59 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/mnit_test/src/test_audio.nit
lib/android/audio.nit
lib/app/audio.nit
lib/linux/audio.nit

index 9ef5d92..ae94e70 100644 (file)
@@ -22,10 +22,10 @@ import android::audio
 
 redef class App
        # Sound
-       var soundsp: Sound
+       var soundsp: Sound is noinit
 
        # Music
-       var soundmp: Music
+       var soundmp: Music is noinit
 
        # Sound
        var easy_soundsp = new Sound("testsound")
@@ -47,8 +47,8 @@ redef class App
                super
                default_mediaplayer.looping = true
                if test_assets then
-                       soundsp = load_sound("testsound.og")
-                       soundmp = load_music("xylofon.og")
+                       soundsp = new Sound("testsound.og")
+                       soundmp = new Music("xylofon.og")
                        soundmp.play
                end
                if test_ressources then
index e985891..d1c50d4 100644 (file)
@@ -658,30 +658,6 @@ redef class App
                App_native_activity(self).setVolumeControlStream(AudioManager.STREAM_MUSIC);
        `}
 
-       # Retrieves a sound with a soundpool in the `assets` folder using its name.
-       # Used to play short songs, can play multiple sounds simultaneously
-       redef fun load_sound(path) do
-               var fd = asset_manager.open_fd(path)
-               if not fd.is_java_null then
-                       return add_to_sounds(default_soundpool.load_asset_fd(fd)).as(Sound)
-               else
-                       var error = new Error("Failed to load Sound {path}")
-                       return new Sound.priv_init(null, -1, default_soundpool, error)
-               end
-       end
-
-       # Retrieves a music with a media player in the `assets` folder using its name.
-       # Used to play long sounds or musics, can't play multiple sounds simultaneously
-       redef fun load_music(path) do
-               var fd = asset_manager.open_fd(path)
-               if not fd.is_java_null then
-                       return add_to_sounds(default_mediaplayer.data_source_fd(fd)).as(Music)
-               else
-                       var error = new Error("Failed to load music {path}")
-                       return new Music.priv_init(null, default_mediaplayer, error)
-               end
-       end
-
        # Same as `load_sound` but load the sound from the `res/raw` folder
        fun load_sound_from_res(sound_name: String): Sound do
                return add_to_sounds(default_soundpool.load_name(resource_manager,self.native_activity, sound_name)).as(Sound)
index 7f22c78..761ba25 100644 (file)
@@ -64,12 +64,3 @@ end
 class Music
        super PlayableAudio
 end
-
-redef class App
-
-       # Load a sound
-       fun load_sound(name: String): Sound is abstract
-
-       # Load a music
-       fun load_music(name: String): Music is abstract
-end
index 297c7e9..938333b 100644 (file)
@@ -50,15 +50,3 @@ redef class Music
        redef fun pause do end
        redef fun resume do end
 end
-
-redef class App
-       redef fun load_sound(name)
-       do
-               return new Sound(name)
-       end
-
-       redef fun load_music(name)
-       do
-               return new Music(name)
-       end
-end