[SOLVED] Audio Problem

Hello Community, I'm testing a web tutorial on my device (http://www.youtube.com/watch?v=6TsDdLY7VXk) , but I have a problem with audio, I'm using my own audio files (.wav), when I test it in the Simulator the app runs perfect, but when I test it into my device, the WinSound and FailSound FAIL!, they are not played, what can I do?

Heres the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--Hide Status Bar
display.setStatusBar ( display.HiddenStatusBar )
 
--Variables
local wScreen = display.contentWidth
local hScreen = display.contentHeight
local mRandom = math.random
local totalCircles = 20
local screenCircles = 0
local gameTime = 10
local gameReady = false
local gameCountdown
 
--Texts
local displayText = display.newText ( "Wait", 0, 0, native.systemFont, 32 )
displayText:setReferencePoint ( display.BottomLeftReferencePoint )
displayText.x = 0
displayText.y = hScreen
local timeText = display.newText ( gameTime, 0, 0, native.systemFont, 32 )
timeText:setReferencePoint ( display.BottomRightReferencePoint )
timeText.x = wScreen
timeText.y = hScreen
timeText.isVisible = false
 
--Audio
local soundtrack = audio.loadStream ( "Soundtrack.wav" )
local tapSound = media.newEventSound ( "TapSound.wav" )
local winSound = audio.loadSound ( "WinSound.wav" )
local failSound = audio.loadSound ( "FailSound.wav" )
 
--Functions
local spawnCircles = {}
local startGame = {}
local removeCircles = {}
local startCountdown = {}
local gameTimer = {}
local statusGame = {}
 
--Main Function
local function main ()
        audio.play ( soundtrack, {loops = -1} )
        local spawnTimer = timer.performWithDelay ( 200, spawnCircles, totalCircles )
end
 
--Spawn Circles
function spawnCircles ()
        local circle = display.newCircle ( 0, 0, 32 )
        circle.strokeWidth = 4
        circle:setStrokeColor ( 255, 0, 0 )
        circle:setReferencePoint ( display.CenterReferencePoint )
        circle.x = mRandom ( 50, wScreen - 50 )
        circle.y = mRandom ( 50, hScreen - 100 )
        screenCircles = screenCircles + 1
        circle:addEventListener ( "tap", removeCircles )
        --Call Start Game Function
        startGame ()
end
 
--Start Game
function startGame ()
        if ( screenCircles == totalCircles ) then
        gameReady = true
        displayText.text = "Go"
        --Call Countdown Function
        startCountdown ()
        end
end
 
--Remove Circles
function removeCircles (e)
        if ( gameReady == true ) then
        media.playEventSound ( tapSound )
        e.target:removeSelf ()
        screenCircles = screenCircles - 1
        --Getting Status Game
        statusGame ()
        return true
        end
end
 
--Start Countdown
function startCountdown ()
        timeText.isVisible = true
        transition.from ( timeText, {alpha = 0} )
        gameCountdown = timer.performWithDelay ( 1000, gameTimer, gameTime )
end
 
--Game Timer
function gameTimer ()
        transition.from ( timeText, {alpha = 0} )
        gameTime = gameTime - 1
        timeText.text = gameTime
        --Getting Status Game
        statusGame ()
end
 
--Ending Game
function statusGame ()
        if ( screenCircles == 0 and gameTime > 0 ) then
        audio.stop ( soundtrack )
        displayText.text = "Win!"
        audio.play ( winSound )
        timer.cancel ( gameCountdown )
        gameReady = false
        elseif ( screenCircles ~= 0 and gameTime == 0 ) then
        audio.stop ( soundtrack )
        displayText.text = "Fail"
        audio.play ( failSound )
        gameReady = false
        end
end
 
main ()

Try using another File Format - maybe the sound is too big.
or change loadSound(..) to loadStream(..)

Maybe that helps!

I see you're using mixed-caps filenames. Make sure your filenames have the same capitalization as you've specified in your main.lua. The simulator is case-*in*sensitive, devices are not.

Perfect, I changed the audio.loadSound to audio.loadStream. Thanks guys.

views:1721 update:2011/11/19 17:31:56
corona forums © 2003-2011