Getting directory path?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting directory path?

Kouma
Hi there,

I'm trying to work out how to play sound in squeak and used this:

(SampledSound fromWaveFileNamed: 'wave file path') play.

Worked fine, but what if I want to add new music from a morph? For instance I have a button, which opens a browser and let me copy the path of a file. How can I take out that path and put in the SampledSound? (providing it copies the path to clipboard)

Also, I couldn't figure out how to play other type like mp3, ogg, mid and so on. Wav is very large to be honest.

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Getting directory path?

Kouma
I'm using this function to copy the path

Clipboard clipboardText: self fullName asText.

Because fullName = the whole thing, or so I think. I suppose I should take it out to something else first, then add that "thing" to the SampledSound function?

Sorry if my msg is confusing, I just knew about squeak like 3 days ago.
Reply | Threaded
Open this post in threaded view
|

Re: Getting directory path?

Sean P. DeNigris
Administrator
(SampledSound fromWaveFileNamed: Clipboard clipboardText string) play ?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Getting directory path?

Kouma
Does work, but it's not what I actually wanted.
For example here:

manager addNewPath: self fullName asText.

I'm using a method to copy the path, but I can't get it out as text to put in the SampledSound function.

I took a look at clipboardText methods and it's just about taking the string from clipboard itself. Do I have to make a new method?
Reply | Threaded
Open this post in threaded view
|

Re: Getting directory path?

Sean P. DeNigris
Administrator
Kouma wrote
manager addNewPath: self fullName asText.
I'm not really sure what you're trying to do.  What is manager here?  Where do you actually try to attempt to use the path?  I think you'll need to post more context i.e. specific code that hits the core classes.

If you're not sure what #fullName returns, as I think you meant in your OP, put a halt in and step through the debugger, or "printIt" from a workspace.

A great place to start for the basics is the free online book "Squeak By Example."  That will get you familiar with the basic tools so you can start to figure out what's going on.

Cheers,
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Getting directory path?

Kouma
In reply to this post by Kouma
Thank you, now it raise another problem:
After playing the sound with SampledSound, I can't stop it midway. The sound will be played from start to finish and can't be stop even when I cancel the project.
I didn't find any hint to stop it in SampledSound class. Any idea?

Cheers.
Reply | Threaded
Open this post in threaded view
|

Stopping a currently played sound (was: Re: [Newbies] Re: Getting directory path?)

Levente Uzonyi-2
On Sat, 4 Dec 2010, Kouma wrote:

>
> Thank you, now it raise another problem:
> After playing the sound with SampledSound, I can't stop it midway. The sound
> will be played from start to finish and can't be stop even when I cancel the
> project.
> I didn't find any hint to stop it in SampledSound class. Any idea?

Send #pause to the sound to stop playing it. After that you can use
#resumePlaying to continue playing the sound where you stopped it, or you
can send #play again to start playing it from the beginning. For example:

| sound |
sound := PluckedSound chromaticScale.
sound play.
1 seconds asDelay wait.
sound pause.
1 seconds asDelay wait.
sound resumePlaying.
1 seconds asDelay wait.
sound play

This will start playing a chromatic scale. It will pause after a second,
then after another second it will start playing from where it was stopped.
Then after a second it will stop and immediately start playing it from the
beginning.


Levente

>
> Cheers.
> --
> View this message in context: http://forum.world.st/Getting-directory-path-tp3071614p3072223.html
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Stopping a currently played sound (was: Re: [Newbies] Re: Getting directory path?)

Kouma
Hi Levente,

Thank for your reply, but it'd be to pause a new sound, not the playing one. Earlier, I played a sound with
(SampledSound fromWaveFileNamed: 'X:/Music/English/Lemon Tree') play.

by clicking a button 'Play'. Now, with that song being played, I made a button called 'Stop' and will use it to stop the currently playing music.

Should I create a new thing as "current playing music" for the method #pause? (we don't have #stop?)
Reply | Threaded
Open this post in threaded view
|

Re: Stopping a currently played sound (was: Re: [Newbies] Re: Getting directory path?)

Levente Uzonyi-2
On Sat, 4 Dec 2010, Kouma wrote:

>
> Hi Levente,
>
> Thank for your reply, but it'd be to pause a new sound, not the playing one.
> Earlier, I played a sound with
> (SampledSound fromWaveFileNamed: 'X:/Music/English/Lemon Tree') play.
>
> by clicking a button 'Play'. Now, with that song being played, I made a
> button called 'Stop' and will use it to stop the currently playing music.

If you store your sound object in a variable or an object, that's
accessible by the actions of both buttons, then you can send the messages
(#play and #pause) to the sound object.

If you don't want to store the sound object in your code, then your
only option is to stop playing all sounds. This can be done by:

SoundPlayer stopPlayingAll.

>
> Should I create a new thing as "current playing music" for the method
> #pause? (we don't have #stop?)

If there were a #stop method, then what would be the difference between
#pause and #stop?


Levente

> --
> View this message in context: http://forum.world.st/Getting-directory-path-tp3071614p3072779.html
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners