mac standalone isn't playing audio

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

mac standalone isn't playing audio

Post by ittarter » Thu Jan 14, 2016 3:34 pm

Hi,

Not sure why, but I can't get my audio to play on Mac standalone.

I'm using the following code I found online to reroute the pathing and it seems to work...

Code: Select all

if the platform = "MacOS" and the environment = "standalone application" then
      repeat until last item of tPath contains ".app"
          delete last item of tPath
      end repeat
      put tPath & "/contents/MacOS" into fld "defaultfolder"
      set defaultfolder to fld "defaultfolder"
However, it still isn't playing the audio...

Code: Select all

set filename of player "check" to "audio conversations/" & gCurrentScenario & "/" & fld "prompt number" & ".mp3"
   start player "check"
I've run checks and it appears like the path is totally fine. Is there some other problem I'm not seeing? I didn't have a problem playing mp3s before so I don't think there's any inherent conflict there. Any thoughts?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mac standalone isn't playing audio

Post by Klaus » Thu Jan 14, 2016 3:56 pm

Hi ittarter,

did you add your sounds/folder(s) via the "Copy files..." tab in the standalone builder?
Then you will find them in -> specialfolderpath("resources"), no need to mess around with "the defaultfolder"!
...
## And ALWAYS use parens when concatenating pathnames (and object names):
set filename of player "check" to (specialfolderpath("resources") & "/audio conversations/" & gCurrentScenario & "/" & fld "prompt number" & ".mp3")
...


Best

Klaus

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: mac standalone isn't playing audio

Post by ittarter » Thu Jan 14, 2016 4:33 pm

Yes, I added the files/folders via the "Copy files" in the Standalone Settings.

Thanks for the pointer re: concatenation. I'm going to try that immediately :)

lol, I use defaultfolder because I don't want to mess with specialfolderpath! I don't really understand how specialfolderpath works. It seems like every OS uses different presets and I don't understand how to coordinate everything...

defaultfolder is easy and it feels like I have clear control - just set it to where the application is, and since I organized everything else in that folder, I can easily add the subfolders etc. to pinpoint specific files.

That being said, I'm obviously running into problems now.

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: mac standalone isn't playing audio

Post by ittarter » Thu Jan 14, 2016 4:48 pm

Still doesn't work...

Code: Select all

set filename of player "check" to (specialfolderpath("resources") & "audio conversations/" & gCurrentScenario & "/" & fld "prompt number" & ".mp3")
The audio works on the Windows standalone.

All the non-audio resources work on the Mac standalone.

It's just the audio that doesn't work on the Mac standalone.

What sorcery is this?!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mac standalone isn't playing audio

Post by Klaus » Fri Jan 15, 2016 10:37 am

Please check my script line and then yours, you forgot one important little character!

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: mac standalone isn't playing audio

Post by ittarter » Fri Jan 15, 2016 2:03 pm

You're right, I missed the slash, but unfortunately the audio player in the Mac version still doesn't work.

Code: Select all

set filename of player "check" to (specialfolderpath("resources") & "/audio conversations/" & gCurrentScenario & "/" & fld "prompt number" & ".mp3")
It's finding non-audio resources in folders - I have a folder with different background images - and it's loading data from .txt files in the root "resource" directory - but it won't play audio from either folder with the mp3s.

Even stranger, past versions of my application HAVE played audio on the mac. .wav files, at least (and I wasn't using the player). Is it possible it's a codec problem of some kind, instead of my amateur coding abilities?

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: mac standalone isn't playing audio

Post by ittarter » Sat Jan 16, 2016 4:59 pm

Hey Klaus,

I got it to work, but not in the way you said. Wanted to share my results and am interested to hear your thoughts.

Code: Select all

put specialfolderpath("resources")
results in nothing, no file path at all. I'm not sure why, but it should produce some kind of text result, yes?

Code: Select all

put specialfolderpath("engine")
According to the current help files, "engine" is supposed to do something. It does, but the file path is wrong.

Livecode builds two sets of folders for its Mac standalone, and one set is empty. I have no idea if the empty folders have a purpose. The real folders that actually get their respective files can be determined by the following code:

Code: Select all

if the platform = "MacOS" and the environment = "standalone application" then
      repeat until last item of tPath contains ".app"
          delete last item of tPath
      end repeat
      put (tPath & "/contents/resources/_MacOS") into fld "defaultfolder"
   end if
   set defaultfolder to fld "defaultfolder"
end if

Code: Select all

set filename of player "check" to (defaultfolder & "/audio conversations/" & gCurrentScenario & "/" & fld "prompt number" & ".mp3")
So yeah, I'm using defaultfolder to access my files, even though you told me not to. Strangely, even without all this "help", my program was always able to determine where to find stuff, except audio files. Perhaps the player object, when setting its source, is much less generous than the rest of the program. Anyway, now the player can find files on the Mac too, and that makes me happy :)

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mac standalone isn't playing audio

Post by Klaus » Sat Jan 16, 2016 5:09 pm

What version of LC are you using?

I think specialfolderpath("resources") was introduced in the late 6.x (or even 7.x?) versions.
In the IDE it should return the folder the current stack lives in.

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: mac standalone isn't playing audio

Post by ittarter » Mon Jan 18, 2016 1:37 am

Community Version 7.0.3.

Code: Select all

put specialfolderpath("resources")
results in nothing in the message box, and put... into... as code in one of my cards results in nothing either, whether as a standalone or as development.

Upgrading to Version 7.1.1 fixes the issue.

So now I can just put specialfolderpath("resources") and that will return the source folder of my program, whether in Mac, Windows or on mobile devices? I'll have to try it out...

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mac standalone isn't playing audio

Post by Klaus » Mon Jan 18, 2016 11:45 am

Hi ittarter,
ittarter wrote:Upgrading to Version 7.1.1 fixes the issue.
great!
ittarter wrote:So now I can just put specialfolderpath("resources") and that will return the source folder of my program, whether in Mac, Windows or on mobile devices? I'll have to try it out...
Why so sceptical? :D
That is the MEANING of specialfolderpathnames! Get usd to them, they are just wonderful!


Best

Klaus

Post Reply