contrib/crazy_moles: update Makefile to use the new check-android.sh
[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 # Sound
25 var soundsp: Sound
26 # Music
27 var soundmp: Music
28 # Sound
29 var easy_soundsp = new Sound("testsound")
30 # Music
31 var easy_soundmp = new Music("xylofon")
32 # testing from assets ?
33 var test_assets = false
34 # testinf from resources ?
35 var test_ressources = true
36 # testing the automatic way ?
37 var test_easy_sounds = false
38
39 redef fun on_create
40 do
41 super
42 default_mediaplayer.looping = true
43 if test_assets then
44 soundsp = load_sound("testsound.og")
45 soundmp = load_music("xylofon.og")
46 soundmp.play
47 end
48 if test_ressources then
49 soundsp = load_sound_from_res("testsound")
50 soundmp = load_music_from_res("xylofon")
51 soundmp.play
52 end
53 if test_easy_sounds then
54 easy_soundsp.load
55 easy_soundmp.load
56 easy_soundmp.play
57 end
58 end
59
60 redef fun input( ie )
61 do
62 if ie isa PointerEvent and ie.depressed then
63 if test_assets or test_ressources then
64 soundsp.play
65 else if test_easy_sounds then
66 easy_soundsp.play
67 end
68 end
69 return super
70 end
71 end