How to play an audio file through a button?
I have a form in which I have a button (Command object). When the user clicks on this command button it is supposed to play a wav file. The wav is residing in my hard disk at "C:\tada.wav"
I have tried to include the following code in the commandAction() method, which technically is the right way of performing this operation:
But I get a warning when I compile saying that this operation should be performed in a seperate thread as opposed to commandAction().
if(c == cmdPlay)
try
String wav = "file:///c:/tada.wav";
Player p = Manager.createPlayer(wav);
p.start();
catch (IOException x)
x.printStackTrace();
} catch (MediaException x) {
x.printStackTrace();
Can anyone please tell me how to implement this solution properly or just suggest a new way of creating a "play" button in my form? Urgent HELP NEEDED PLEASE!
THANKS.
Hi Ibrahim,
Rob has pointed you to the Lingo for playing a sound. There is a behavior in the Library Palette that makes this very easy without needing to write a script yourself. In the Media > Sound category, there is a 'Play Sound' behavior. You can click and drag this behavior onto a sprite and then in the Parameters dialog, you can choose the sound to play, the channel in which it should play, the event to activate the sound, and if you want the sound to loop.
Dean
Director Lecturer / Consultant / Director Enthusiast
http://www.deansdirectortutorials.com/
http://www.multimediacreative.com.au
Similar Messages
-
How to play a wave file through the DAQ board?
Hi there,
we want to play a wave file that is saved on the harddrive via the DAQ board. Means we want to connect a amp to the analog output of the DAQ to amplify the sound and play it through a speaker.
We couldn't find any VI that does that. Can anybody tell us how to play a wave file, or perhaps even send us a VI that can do that?
Thanks a lot for your help
Martin - Physical Optics CorporationHi Martin,
The only example that I could find on how to do this was using our
older Traditional DAQ drivers version 6.9.3. If you're using Traditional
DAQ drivers, the vi can be found here.
The example reads a 8-bit mono .wav file (an example .wav file is included in the .zip file) and writes it to the analog out of your DAQ card. I've updated the
example to work with our newer DAQmx drivers and attached it here.
I hope this helps,
Paul C.
Message Edited by Paul C. on 08-14-2007 05:47 PM
Attachments:
daqmx_wav_file_to_ao_output.zip 27 KB -
Hello to everybody,
I am working on a application that is supposed to manage audio file. At the moment I 'm using the SourceDataLine instead of the Clip. But I've got a problem. When the user pushes the Stop button I want that if he pushes Play again the track starts from the begin. I've used the drain() and flush() method but it doesn't work because the track resumes from the point when has been interrupted. Here part of the code:
@Override
public void run()
try
if(dataline!=null)
dataline.open(audio_format);
dataline.start();
int i=0;
while((i=audio_input_stream.read(buffer, 0, buffer.length))!=-1 && flag==false)
if(i>0)
dataline.write(buffer, 0, i);
dataline.drain();
dataline.stop();
dataline.flush();
dataline=null;
dataline.close();
And also I'd like to know how to navigate through the audio file by a slider or something like that, so how much time is passed.
Thank you in advance.
Maurizio Di Vittomauriziodvt wrote:
I've tried to use it but I found out that if I use quite large wav files an exception is thrown, Aha! I expected as much. That is why I developed BigClip.
..so I thought to change to SourceDataLine even if Clip has the right stuff to manage my audio files. So what do you suggest? Is there a way to avoid such problem? I mean, how can I be sure that I'm able to use every wav files? Not every WAV file can be opened using SourceDataLine, but if SDL can open it, so can BigClip. -
How to play the audio file please help me
i would like to play audio files such wav files, au files etc
I would like to know how to play audio file easily in Applet and
applications
Thank youimport sun.audio.*; //import the sun.audio package
import java.io.*;
//** add this into your application code as appropriate
// Open an input stream to the audio file.
InputStream in = new FileInputStream(Filename);
// Create an AudioStream object from the input stream.
AudioStream as = new AudioStream(in);
// Use the static class member "player" from class AudioPlayer to play
// clip.
AudioPlayer.player.start(as);
// Similarly, to stop the audio.
AudioPlayer.player.stop(as); -
How to play an audio file when a sprite is clicked
I am designing a Director movie in order to learn how to use the program. My question is how can I make a small audio file play when the user clicks on a sprite? I believe it is done via a small script. My second question is similar. How can I make the movie play a sound when the cursor hoovers upon a sprite? Can you help, please? Thanks in advance.
Hi Ibrahim,
Rob has pointed you to the Lingo for playing a sound. There is a behavior in the Library Palette that makes this very easy without needing to write a script yourself. In the Media > Sound category, there is a 'Play Sound' behavior. You can click and drag this behavior onto a sprite and then in the Parameters dialog, you can choose the sound to play, the channel in which it should play, the event to activate the sound, and if you want the sound to loop.
Dean
Director Lecturer / Consultant / Director Enthusiast
http://www.deansdirectortutorials.com/
http://www.multimediacreative.com.au -
How to play .mht audio file
My professor is presenting her notes in an .mht audio file. I have downloaded google chrome, firefox to no avail.
Any suggestions?import sun.audio.*; //import the sun.audio package
import java.io.*;
//** add this into your application code as appropriate
// Open an input stream to the audio file.
InputStream in = new FileInputStream(Filename);
// Create an AudioStream object from the input stream.
AudioStream as = new AudioStream(in);
// Use the static class member "player" from class AudioPlayer to play
// clip.
AudioPlayer.player.start(as);
// Similarly, to stop the audio.
AudioPlayer.player.stop(as); -
How to play an audio file using applicationMusicPlayer ?
It's easy to play a file using AVAudioPlayer
NSBundle *mainBundle = [NSBundle mainBundle];
NSError *error;
NSURL *tickURL = [NSURL fileURLWithPath:[mainBundle pathForResource:@"tmp" ofType:@"amr"]];
tickPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:tickURL error:&error];
[tickPlayer play];
But how to play a file using applicationMusicPlayer?
I know setQueueWithItems, but how to prepare the items for it?seems not a good question
-
How to play mp4 audio files as video on my iPod Touch?
I know you are all thinking that this is a stupid question based on the topic, but I have videos for some reason that are in the form of mp4 audio, but they are video when I play them on my computer. I can open these videos (mp4 audio instead of mp4 video) using Windows Media Player and it's not just audio, there is also video. However, whenever I try to sync it to my iPod, it shows up in my music section instead of videos. If i play the video under music, all I see is the white iTunes background, no video. Is there anyway for me to set these files to be recognized as video and store it under my movies category?
Thanks.First, go into Get Info and change the Media Kind on the Options tab to tell iTunes that this is a video. Next, you need to sync this item from the Video tab on your iPod detail in iTunes (i.e. don't sync it as if it was a Music item). If you sync all video content then this will happen automatically once you change the Media Kind. But if you only sync part of your video library, make sure you include this video in the sync selection.
If you still have problems, you may need to convert the video for iPod playback, even if it plays fine in iTunes. If that's the case, right-click on the video and you'll see an option to convert for iPod use, which will make a copy (so make sure you know which version to sync to the iPod, or simply delete the original). -
How to play other audio files in Podcasts app?
Hi all. Whenever I add audiobooks or recordings of radio shows to my iPhone, they go into the Music app. However, this doesn't have a placeholder function (that is, it doesn't remember at which you point you paused the file) or a sleep timer like the Podcasts app does. I find this really annoying, especially the lack of placeholder. Is there any way to get these things to play from Podcasts instead? I've searched on this but can't find any other questions about it. Surely other people find this irritating as well? Hoping there is some solution, maybe using a third party app?
Close Windows Media Player. Make sure you know where the song files are on your hard drive. Use the iTunes command File > Add File (or Folder) to Library.
If they are MP3s they will add directly to your iTunes library. If they are non-protected WMA files, they will be automatically converted and added. If they are something else, "measures" must be taken...
Let is know how this works! -
Using embed tag....how to play an audio file
i want to play a song with windows media player and added this tag to my code...
<embed src="onlytime.mp3" width="132" height="132" ></embed>
but nothing is shown in the page....
i cant understand the plugin thing.....should i copy the content of plug in folder of the media player to internet explorer plugin folder?
plz help...seems not a good question
-
HOW TO OPEN *.DAT(VIDEO) FILES THROUGH A BUTTON
I want to know how one could make a dat file open by action event on a button.
suppose there is a particular movie file say sanket.dat and ur button is clicked then first the
opening exe file say sthvcd.exe(Super Decoder ) and enter the file sanket.dat as the variable of the decoder.
.....SanketI don't know how to do all video, but each extension, find a file with that extension, get info, change the "open with," and then click on change all.
-
How do I play an audio file as a soundtrack for entire keynot
How do I play an audio file as a soundtrack for entire keynote?
https://developer.apple.com/mac/library/samplecode/PlayFile/Introduction/Intro.h tml
Docs are your friend....mac os has it's own just like iPhone. -
How do you get audio files to loop instead of playing just once.
how do you get audio file to loop instead of playing just once.
ThanksThis forum is specifically meant for Edge Inspect issues. Could you please let us know the product your query is related to. We will redirect you to the correct forum.
-
How to delete unused audio files in a project?
Hi guys,
The question is fairly simple:
How to delete unused audio files in a project?
I can't manage to find the answer in the manual,... all I could find is how to delete audio outside used regions!
But in the projects I use, I have loads of outtakes which I don't use in the project anymore, and now, I would like to delete them of the audio folder to save space on the HD.
Can Logic select automatically the takes in the audio files folder which are not used in the project and delete them??
Because there is hundreds of audio files per project, and +/- 50 projects, I just can't do it manually.
Thanks,
FredWhoops! Yes, I knew that but a cow flew by... Sorry!
The procedure I follow is to do what I described then Save as Project, creating a project folder. That way only the required audio is saved to the folder and I delete all temporary stuff. However, if you have folders with shared material, it's much harder and would require you to go through all your projects doing Save as Project before you could delete your old working folder.
When doing day to day work, best practice is to create a new folder and only use Save as Project when you're working on stuff. Shared material (eg sample libraries etc) can go elsewhere and you can get Logic to copy those to the project folder automatically.
Otherwise, Shift-Backspace in the Audio window, as you rightly say
Pete -
How to add an audio file to a link
I am working on a project using IWeb and I am trying to figure out if it is possible and then, if it is how to add an audio file to a link. I would really be glad of your help as I am having problems meeting the requirements of the project if I don't make it work.
Also, is it possible when having added a movie clip from quick time player to have the clip start as soon as the page is "opening", that is without pressing the play button?
I am waiting in great suspense to see if anybody can help me out. If you have the answers to my questions, please send me an email at [email protected] - thank you so much :o)Hi Maiken
Welcome to the discussion forums.
All you need is open iWeb, select text or image, open inspector, go to link, check the "enable as a hyperlink" box, in "link to" there's a teardown menu where you select "a file" and select the file you want to link to.
If you want to have it downloading look at [this|http://alyeska.altervista.org/en/iWeb_Downloads.html]
For the second question:
select the movie file in iWeb go to inspector, then to the last icon (showing the quicktime logo) and check the box that say "Autoplay".
Regards,
Cédric
Maybe you are looking for
-
so my ipod touch screen is broken, and whenver i try to unlock the ipod screen, all that i can see is the top right hand corner of my ipod, and the rest is all whited out. Also, the jack which support the headphones to stay in place, one of the balls
-
Can't transfer files even though I created them
I'm trying to transfer music, iPhoto, and other files to my new iMac so I can erase my MacBook (many, many problems since upgrading to 10.5, but that's another story) and do a clean install. However, when I try to transfer them, using TDM or just ove
-
HT1926 I updated itunes and now it doesnt recognize my CD drive
I updated Itunes and now it doesnt recognize my CD drive
-
When I add hyperlinks to other Keynote pages they work fine in Keynote and on the exported Quicktime movie. However, when I then embed the Quicktime into a web page and upload it, the links are dead on the webpage. Any suggestions?
-
Plug-in not loading - Audition 2.0
I tried using the ADT plug-in (from http://www.vacuumsound.de/plugins.html) in Audition 2.0. It's not even recognized when I try to look for it on my plug-ins list. Other plug-ins from that site seem to load and work fine in Audition. Tried the AD