decf7c54a3b2b8367de280cdaea4489a6ccde40e
[nit.git] / examples / mnit_simple / src / test_audio.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2014 Romain Chanoir <romain.chanoir@viacesi.fr>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Test for the audio module of App.nit framework
18 module test_audio
19
20 import simple_android
21 import android::audio
22
23 redef class App
24 var soundsp: Sound
25 var soundmp: Sound
26
27 redef fun init_window
28 do
29 super
30
31 default_mediaplayer.reset
32 manage_audio_mode
33
34 # Retrieve sound
35 soundsp = load_sound("sound.ogg")
36 soundmp = load_music("xylofon.ogg")
37 default_mediaplayer.looping = true
38 default_mediaplayer.prepare
39 soundmp.play
40 end
41
42 redef fun input( ie )
43 do
44 if ie isa PointerEvent and ie.depressed then
45 soundsp.play
46 end
47 return super
48 end
49 end