Panorama X media catalog to play audio files

Panorama X media catalog to play audio file

I have an eight field database of about 7,000 OTR audio files. In addition to using the database to manipulate and analyze the OTR catalog, I would like to be able initiate play of the selected audio file from within the database.

I can create a field with the local path+file name, but I cannot see a way to have Panorama X trigger that file to open in its native Quicktime player.

Is it possible? How?

iMac, Mojave

Try the openanything statement.

For me using openanything for a sound file will open iTunes to play it. If you want to be sure to play in in the QuickTime Player you would use the openwith statement. Here is an example that will open the QuickTime Player with the current sound listed in a field called theSounds:

openwith "QuickTime Player",theSounds

In QuickTime Player the sound does not auto-play and you have to manually play it. In iTunes the sound automatically plays when opened. If you want it to automatically play in the QuickTime Player you might have to try an AppleScript to get it done.

gary,

Two for two.

openwith “QuickTime Player”,pathName worked first time.

The result I was looking for.

Thank you.

Wouldn’t be cool if there was a “sound” verb in Panorama. For example, you could have a database with photos of different birds and when the form opened or the photo changed, a sound file of the bird call would play. I’m sure I’ve seen something like that somewhere before. Seemed like a pretty neat feature.

A year ago I put together a little demo file for showing some various object effects. That database file also had a little gimmicky effect that had a bee flying across the screen while making a buzzing sound. The sound was generated by an invisible Web Browser Object that was created on the fly off the right side of the form. When the “Kill Bee” button is pressed the Web Browser Object is deleted, the bee disappears and the sound stops. The code that creates the Web Browser is in the .Buzzer procedure which executes the Bee.mp3 sound file that is included in the same folder. Here is that code:

object "Buzz"
deleteselectedobjects
// create formula
let theFormula={"<!DOCTYPE html>
<html lang=""en"">
<head>
</head>
<body>
    <audio autoplay loop>
    <source src=""file://}+unixpath(dbpath())+{/Bee.mp3"" type=""audio/mpeg"">
    </audio> 
</body>
</html>"}
// create web browser with autoplay sound file off window
Newformobject "WebBrowserObject",
    "$WebBrowserFormulaMode","Formula",
    "rectangle",rectanglesize(1, rright(info(“windowrectangle”))+100, 1, 1),
    "name","Buzz",
    "Formula",theFormula

This is a screen shot of that database showing the bee in flight:

image

You can also check out the various effects by clicking any of the top four buttons. The zipped folder containing the database and the sound file are here:

http://www.unseensoft.com/PanX/ObjectsEffects.zip

1 Like

These procedures will play the sound asynchronously.

The shellscript way …

local tFile, tCommand, tResult

tFile = posixpath(“/Users/username/pathToFile/File Name To Play.m4a”)

tCommand = {afplay } + tFile + " > /dev/null 2>&1 &"

shellscript tCommand, tResult

… and the applescript way …

local tFile, tCommand, tResult

tFile = “/Users/username/pathToFile/File Name To Play.m4a”

tCommand = {set soundPath to “} + tFile + {”
do shell script “afplay " & quoted form of soundPath & " > /dev/null 2>&1 &”}

applescript tCommand, tResult

Omit the " > /dev/null 2>&1 &", and Panorama will come to a dead stop, until the sound completes.

afplay is a utility included in OSX since 10.5 (look in /usr/bin), but doesn’t play protected audio files. It handles most audio file types, though. A potential advantage of afplay over QuickTime is it’s process opens and closes without the user being aware.

The background for this came from Mac OS X Hints. A search for ‘regulus’ on that page will show the code used in these examples. A few other suggestions there may also be worth exploring.

Like PlaySound in Panorama 6?

James - Oh, much older that that. I believe it was at least in Pan3. It was one of the first example programs provided with the database. It had some bird photos - to show off flash art. And it played the bird sounds - FlashAudio - as they were brought up in the form. I always thought it was cool and could imagine other uses. But it didn’t seem to generate much enthusiasm. So I was kind of joking with Jim with my post.

In Panorama 6 and earlier, the playsound statement was only usable with antiquated sound resources and only after first opening the resource with opensound…

Eric’s solution seems the easiest to implement today but does have one restriction in that it will not allow a sound to repeat (loop) until turned off. I found a hack to loop the afplay sound but there was a noticeable delay between each loop. Worse than that, I could not stop the sound from playing even with a killall afplay command in the terminal and I had to restart my computer to get rid of it. So, for the use I needed it was only the Web Browser scheme I showed previously that allowed for continuous sound play.

For Eric’s scheme you could use shellscript {killall afplay> /dev/null 2>&1 &} on a “Stop” button to turn the playing sound off when needed. You can also incorporate the afplay -v option to set the playback volume between .01 (lowest volume) and 1 (highest volume). Here is code to play my Bee.mp3 sound file in the same folder as the database at a volume of 60%:

let theSoundFile=dbpath()+{Bee.mp3}
shellscript  {afplay } + posixpath(theSoundFile)+{ -v .6> /dev/null 2>&1 &}

One further note, I just had to find out what the trailing entries were used for in Eric’s shellscript. The {> /dev/null 2>&1 &} part of the shellscript is to prevent any errors from being returned and allowing the script to execute asynchronously in the background.

Today I exported the Internet Radio streams of my Mojave’s iTunes as playlists (in order to transfer them into Catalina’s Music.app). I noticed that those playlist exports are tab separated text files. So I made a Panorama X database out of these text files, and when this was completed, I wanted to be able to start the playback of the streams from within my database.

A little bit of research led me to the excellent site Doug’s Apple Scripts, and then it was very easy to implement a little AppleScript that plays the stream of the active record in iTunes:

applescript |||
tell application "iTunes"
    open location ||| + quoted(URL) + |||
end tell
|||

I was only looking to play a local audio file directly from PanoramaX.

It was solved with: openwith “QuickTime Player”,pathname

But your script opens new possibilities that I will explore.

Thanks.