hmmm, this is interesting. I’m trying to get the sound I’ve loaded and played to loop.
I’ve got…
set soundName to “MySound.mp3”
set soundsPath to the resource path of main bundle & “/Alert Sounds/”
set AlertSound to load sound (soundsPath & soundName)
set AlertSound to load sound (path to me)
play AlertSound
And that all works fine.
I tried changing play AlertSound to play AlertSound with looping yes
But that wouldn’t compile. It didn’t like the word yes. I tried changing that to true but it didn’t like true either so I tried it just ending it at looping.
play AlertSound with looping
And the word looping turned green indicating a variable name.
That really surprised me that it didn’t even recognize the word looping.
I tried taking off the ing making it just loop but that had no affect.
set sndPath to POSIX path of (choose file with prompt "choose sound file")
set snd to load movie sndPath
tell movie view "mv" of window "main"
set it's movie to snd
set it's loop mode to looping playback -- or 'looping back and forth playback' or set this in Interface builder
play
end tell
That’s correct - but it is invisible if you don’t show visible content and hide the controls.
EDIT: I just tried for curiosity: It is even possible to set the size of an NSMovieview to 0/0 in Interface Builder and it will still do it’s job
If you don’t want this, then it might be possible to create one only when needed at runtime (will need some objective-c) or I think I’ve once read sth about a scriptable faceless application that has this feature (sorry, I don’t remember the name and have no idea if it was freeware - maybe you’re successful with google/version tracker … ?)
EDIT:
Or - if you don’t need a real loop - maybe continously repeating the play command is sufficient in your case? You could do this without having a blocked user interface when using the on idle handler - for example:
property alarmOn : false
global snd
on awake from nib theObject
set snd to load sound "path/to/the/sound"
end awake from nib
on clicked theObject
set alarmOn to (not alarmOn)
end clicked
on idle theObject
if alarmOn then
play snd
end if
return
end idle
Wow thanx for all of the options and help. movie view is the way to go but I don’t see it in the pallet in the interface builder. where do i find that?
either use a custom view and set it’s custom class to “NSMovieView” in Interface Builder (Apple + 5)
or an other opportunity would be to download and install bMoviePalette: http://developer.apple.com/samplecode/bMoviePalette/index.html - it brings you a new palette with three elements: NSMovieView, SoundFileWell and a custom one (MovieEditingController)
The advantage of the second option was, that you can make some more settings for the NSMovieView in Interface Builder
I don’t understand how to install this. I expected a typical installer bundle but this looks more like an xcode project. with no installation instructions. Do I just open the poject in xcode and build it?
If there is no prebuilt palette included (‘bMoviePalette.palette’) then - yes build it in Xcode. To install the palette drag it to /Developer/Palettes/ and restart Interface Builder
That’s correct - but it is invisible if you don’t show visible content and hide the controls.
OK the looping works great but how do I hide the controls?
I’d rather not set the size of the player to 0x0 as that makes it difficult to select the movie view item in IB when editing. I’ve got it set to 20x20 which makes it big enough to have something to select in IB but when I build and run the play/pause button appears.
I’m assuming there’s some applescript command to hide the controls like with controls hidden or something?
To select a 0 x 0 pixel element in Interface Builder you can switch the view mode of the instances tab of Interface Builder from icon to list view (using the two tiny square buttons in the upper right)
Okay now I’m trying to controll the volume of the snd being played back so before I bothered putting in a slider I wanted to make sure I could actually control the volume so I tried…
set sndPath to POSIX path of (choose file with prompt "choose sound file")
set snd to load movie sndPath
tell movie view "mv" of window "main"
set it's movie to snd
set it's loop mode to looping playback -- or 'looping back and forth playback' or set this in Interface builder
set it's volume to 5
play
end tell
It compiled okay but it seemed to have no effect at all. so then i tried 0.5 and that still had no effect.
set sndPath to POSIX path of (choose file with prompt "choose sound file")
set snd to load movie sndPath
tell movie view "mv" of window "main"
set volume 5 --- or what ever number between 1 and 7 acording to the other post. That seems odd though. Would have thought 1 - 10
set it's movie to snd
set it's loop mode to looping playback -- or 'looping back and forth playback' or set this in Interface builder
play
end tell
I really need help with this. I’ve been trying different things and find several different ways that compile with out error but nothing that has any effect on the volume of playback.
Currently I have the following code in bothe the on awake from nib handler and in the on will open handler of the window containing the movieView…
tell movie view "Sound Test Player" of theObject
set it's volume to 0.2
set it's movie to AlertSound
set it's loop mode to looping playback
end tell
Even tried putting this in the on launched handler…
Holy cow! I thought I thought of a hackish wat of doing it by using interface scripting to gain access to the volume slider that exists in the movie controller of my movie view so I launched UI browser and low and behold the controler is an unknown UI element with no children. So I can’t even get access that way.
Why must there be a road block at every turn? /me is banging his head. thump thump thump.