Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Audio Loop Not Working
Started by jongarsman1076 May 09 2018 01:31 PM

2 replies to this topic
audio loop music api
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jongarsman1076

[GLOBAL: userInfoPane.html]
jongarsman1076
  • Observer

  • 2 posts
  • Corona SDK

Hi All,

I can't seem to get my loop working on this audio clip.  It is probably very simple and i'm just overlooking it as i'm new to Corona.  Any help would be greatly appreciated and rewarded with an emjoi!  Here is my code.

local piano2 = display.newImage("button1b.png", 40, 50);
piano2.status = "waiting";
 
local piano2Sound = audio.loadSound("piano2.mp3");
 
function piano2:tap(e)
if(self.status == "waiting") then
audio.setVolume( 0.5 )
audio.play(piano2Sound,{
channel = 1,
loop = -1,
onComplete = function(e)
self.status = "playing";
end
});
 
elseif(self.status == "playing") then
audio.pause(1);
self.status = "paused";
elseif(self.status == "paused") then
audio.resume(1);
self.status = "playing";
end
end
 
piano2:addEventListener("tap",piano2);


[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,119 posts
  • Corona SDK

@jongarsman1076,

 

Welcome to the forum.

 

1. You have 'loop'.  The correct name is 'loops'.

 

https://docs.coronalabs.com/api/library/audio/play.html#options-optional

 

 

2. Please use the built-in post editing tools to format code posts:

formatyourcode.jpg



[TOPIC: post.html]
#3

jongarsman1076

[GLOBAL: userInfoPane.html]
jongarsman1076
  • Observer

  • 2 posts
  • Corona SDK

I knew it wasn't something dumb I was missing.  Thank yoU!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: audio, loop, music, api