Player can't 'see' external audio file on all computers

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Player can't 'see' external audio file on all computers

Post by thomthib » Thu May 21, 2015 8:17 pm

Summary: I link an external audio file to a player. Everything works fine unless I move it to another computer. Then the player is 'dead'.


I have a stack that is located inside the folder 'TestPlayer2'. There is a sub-folder called 'AudioFolder' also located inside the main folder 'TestPlayer2'. Inside the sub-folder, 'AudioFolder', is an mp3 audio file.

The stack has a button with a script that creates a player and links it to the external audio file in the folder 'AudioFolder'.

The script works fine and the player plays the audio file with no problems.

The problem occurs when I create the player, link the external file, and then move the folder 'TestPlayer2' to another computer. When I click on the player on the second computer, the sound doesn't play.

I'm using a default folder and relative path name as I understand the concept. Apparently something in my knowledge is missing.

I understand that when you move files to another computer, the path name changes in the first few nodes. However, the path name starting with 'TestPlayer2' should be the same on every computer: " ../TestPlayer2/AudioFolder/myaudiofile.mp3"

In the stack script I establish a defaultFolder with the following script:
---------------------------------------------------------
on preOpenStack 
  set itemDel to "/"
  set the defaultFolder to item 1 to -2 of (the effective fileName of this stack)
end preOpenStack
--------------------------------------------------------------------------

The button that creates the player and associates it with the external mp3 file has the following script:

----------------------------------------------------------
on mouseUp

set the itemDelimiter to "/"

answer file "Pick a file"      --PROMPT TO SELECT THE AUDIO FILE IN THE SUB-FOLDER, "AudioFolder"

put it into fld "textAudioFilename" --PUTS THE COMPLETE PATH NAME OF 'IT' INTO A FIELD


---THE FOLLOWING 3 STEPS MODIFY THE COMPLETE PATHNAME BY STRIPPING OUT THE FIRST FEW STEPS UNIQUE TO EACH COMPUTER-----

       
put item -3 to -1 of fld "textAudioFilename" into fld "textAudioFilename"  --REMOVES STEPS IN PATH PREVIOUS TO FOLDER 'TestPlayer2

put "../" before first char of fld "textAudioFilename" --ADDS "../" BEFORE PATH NAME TO POINT TO PREVIOUS STEPS ON PATH
 
put fld "textAudioFilename" into theFileToPlay --PUTS CONTENTS OF FLD "textAudioFilename" INTO A VARIABLE

---------------------------------------------------------------------------------------------------------------------------------------------------------
create player "jokeAudio"  --CREATES THE PLAYER

set the filename of player "jokeaudio" to theFiletoPlay --LINKS PLAYER TO EXTERNAL AUDIO FILE

----------SETS PLAYER PROPERTIES-----------------

set the showcontroller of player "jokeAudio" to true
set the height of player "jokeAudio" to 26
set the width of player "jokeAudio" to 200
set the loc of player "jokeAudio" to 200,200
show player "jokeAudio"

end if
end mouseUp

----------------------------------------------------------------------------------------------
What am I missing so that the player will 'see' the external audio file on any computer?

Thanks!!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Player can't 'see' external audio file on all computers

Post by Simon » Thu May 21, 2015 8:44 pm

Hi thomthib,
I think this applies to your situation;
http://quality.runrev.com/show_bug.cgi?id=14435
If not ignore this post :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

thomthib
Posts: 17
Joined: Wed Mar 05, 2014 1:09 am

Re: Player can't 'see' external audio file on all computers

Post by thomthib » Fri May 22, 2015 3:05 pm

Thank you Simon. I am using Livecode 7.0.4 so according to the bug report, this should be resolved. In any case, your reply helps narrow down my search for an answer so I appreciate your response.

okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Re: Player can't 'see' external audio file on all computers

Post by okk » Tue Dec 01, 2015 12:43 am

Hi, you can also try following to set the path to the folder in which your stack/standalone application is located.

Code: Select all

  
on OpenStack
   global tPath
   -- set the path to home folder
   put the filename of this stack into tPath
   set the itemdelimiter to "/"
   
   --define filepath based on environment
   if the environment is "development" then
      -- only for development environment (and perhaps for windows, but I am not sure about this)
      delete the last item of tPath 
   else
      -- only for standalone
      delete item the number of items of tPath -3 to the number of items of tPath of tPath 
   end if
   set the filename of player "jokeAudio" of card "???" to tpath & "/AudioFolder/" & myaudiofile 
end OpenStack
myaudiofile would contain only the name of your audiofile, e.g. myaudio.mp3 You can extract this name for example from your textfield "textAudioFilename".
This works for sure in a Mac environment, for Windows, Linux etc. I am not certain. The advantage is that this works both in the Livecode environment and when deploying to a standalone application on whatever computer or external disc you have your stack located. You only have to make sure the folder with your audio-files stays in the same relation to the stack.

Best
Oliver

Post Reply

Return to “Multimedia”