Best practices for desktop/mobile multimedia development?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Best practices for desktop/mobile multimedia development?

Post by ctflatt » Sat Jan 15, 2011 1:02 pm

Hello, everyone.

I have been working on a project for several weeks that could only have been possible with the help of this forum. For that I thank everyone who responded to a previous post on my behalf.

I am now at a point where the mobile version is almost complete and my client wants a desktop version. My dilemma now is this:

The project is scripted entirely for mobile. While most of the scripts will translate to the desktop, the project has MANY sound files that are triggered by elements on several cards. It took a lot to figure out mobile sound, but now the project has to be coded for the desktop.

Is there a best practice process for converting the scripts I currently use for mobile sound to the desktop?

A typical script looks like this:

Code: Select all

on mouseUp
play specialFolderPath("engine") & "/english/01.mp3"
end mouseUp
All sound files are contained in categorized folders which changes the pathname to the resource.

If there is a way to take my existing code and easily script a change to this for desktop compatibility?

I think I have to include a player control on each card for the desktop, and supply it the path to the file to play.

Not sure if this is the right forum, but since I'm starting from a mobile code base, I thought I would start here.

If I need to provide any more information, please let me know.

Thanks!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Best practices for desktop/mobile multimedia development?

Post by bn » Sat Jan 15, 2011 3:11 pm

Hi ctflatt,

It depends a little how you want to add your folders with the sound file. Lets assume you want to include them with your program by choosing in the standaloen application settings-> copy files ->add folder.
Then on a Mac this folder is in the app bundle next to the tempPlayer. This is the name I gave the test stack. And I saved the standalone to the desktop in a folder that has the same as the app name (this is all automatically done by Livecode once you point it to a destination folder when building the standalone
/Users/userName/Desktop/tempPlayer/tempPlayer.app/Contents/MacOS/tempPlayer
this is what "the effective filename of this stack" returns.
If you include a folder in the above way it will be at the level of your app in the above path or, the other way around in
/Users/userName/Desktop/tempPlayer/tempPlayer.app/Contents/MacOS/tempPlayer
folder

This is what you get if you issue a

Code: Select all

 put item 1 to -2 of the effective filename of this stack into tPath
tPath would contain the path to the folder your folder with subfolder is in.

From there it should be easy to go on. In my templayer test I set a custom property "uPathToFolderOfMyFolder" of the stack on openstack

Code: Select all

on openstack
   set the itemDelimiter to "/"
   put item 1 to -2 of the effective filename of this stack into tPath
   set the uPathToFolderOfmyFolder of this stack to tPath
end openstack
in a mouseUp button I then have:

Code: Select all

 if not exists (player "myTempPlayer") then
      reset templateplayer
      set the visible of the templateplayer to false
      set the name of templatePlayer to "myTempPlayer"
      create player
   end if
   put the uPathToFolderOfmyFolder of this stack into tFolder
   put tFolder & "/" & "english/" & "nameOfYourMP3here.mp3" into tmyPath
   set the filename of player "myTempPlayer" to  tmyPath
   start player "myTempPlayer"
another button to stop the player

Code: Select all

on mouseUp
   stop player "myTempPlayer"
end mouseUp
since the players are created in a standalone, they will not be saved and will be recreated on the fly the next time you start your program.

This is not best practice, this is quick and dirty and you have to see how it works. Of course better practice would be what you said: create a player permanently and change the script of the buttons.

You could write a script that extracts the filename and foldername from the button script and replace this with the above script and inserting a folder file automatically. If you attempt this you would want to do it on a copy of your stack.

For windows the path to the included folders might be a little different, so someone would have to add that information. Here are some informations pertaining to the paths
http://lessons.runrev.com/spaces/lesson ... nd-Windows

So actually it all depends how much time and effort you want to put into this. It is really not that difficult.

Kind regards

Bernd

Post Reply