How to play 2 sequentially sounds of a button using MediaPlayer?
Hi all
It can be quite simple and I'm just been staring at this long, so I don't get it. Basically, I want to have a single button and when I click on it, depending on the settings, can play a sound or two sounds (or 3 or 4..) in the order.
I stated my MediaPlayer:
MediaPlayer {}
ID: mPlayer
},
Then in my code, I would dynamically set the SourceUrl:
if (SomeApp. getValueFor ("Option 1", "false") == 'true') {}
mPlayer. setSourceUrl (item.someSound)
mPlayer. play ()
if (SomeApp.getValueFor ("Option 2", "false") is 'true') {
mPlayer.setSourceUrl (item.anotherSound)
mPlayer.play)
}
.......
What happens now, it's the 2nd sound replaces the first sound. I need some kind of break or report the arrival of first sound entered the 2nd sound comes...
Thank you
Pseudocode to show the idea:
Create the QList
then add the sound to play when do: in playbackCompleted() Manager:
if (mSoundsToPlay.isEmpty())
{
mSoundsToPlay.push_back(soundName);
...start playing soundName...
}
else
{
mSoundsToPlay.push_back(soundName);
}
mSoundsToPlay.pop_front();
if (!mSoundsToPlay.isEmpty())
{
...play next sound from mSoundsToPlay.front()...
}
Tags: BlackBerry Developers
Similar Questions
-
Play sounds in the order using MediaPlayer
Hello. How to play sounds in order?
For now, here are my code.
I have a MediaPlayer component as an attached object
http://developer.BlackBerry.com/native/reference/Cascades/bb__multimedia__mediaplayer.html
attachedObjects :[ MediaPlayer{ id: sound sourceUrl: "asset:///sounds/sound1.mp3" } ]
Then I have a button. Here is what my code for it
Button{ id: play text: "Play Sequence" onClicked :{ sound.sourceUrl = "asset:///sounds/sound1.mp3" sound.play(); sound.sourceUrl = "asset:///sounds/sound2.mp3" sound.play(); sound.sourceUrl = "asset:///sounds/sound3.mp3" sound.play(); } }
What goes wrong.
The code runs after 1 second about, cut the next sound. I'm doing his next game, after the end of his previous.
The sounds are not finished because play() is not a call blocking. Once you call the play() function it will start playing the sound and return immediately to the following line of code in the QML. If the next line is a call to the play() still it will have precedence over previous sound, i.e. If you think logically about what you need in an application, you would not have the sound of a doorbell 2 seconds later, play just because you play already a sound, you would stop, as it does.
My suggestion to use a selection intended to use the MediaPlayer playlist function, that you implemented will obviously suffer from the same problem for the above reason. A playlist is a separate file that contains a list of media you want to play and can be in different formats.
My other suggestion of using onPlaybackCompleted does not seem to have been followed by you, but is probably the easiest to implement.
MediaPlayer { id: mediaPlayer onPlaybackCompleted: { count = count + 1; var s = count; mediaPlayer.setSourceUrl("asset:///sounds/sound" + s + ".mp3"); mediaPlayer.play(); } }
Where count is a comprehensive, defined property to 1 in your QML file and you have some relaxation (onCreationCompleted or clicking a button) to start the first play().
-
How to play a little sound at the opening of my AIR application?
Dear friends:
I created a small application, which displays a Web site on the inside, but I want a sound to play when some users open the AIR application... How do I do this? Thanks in advance...
http://livedocs.Adobe.com/Flex/3/HTML/Help.HTML?content=Working_with_Sound_05.html
http://livedocs.Adobe.com/Flex/3/HTML/Help.HTML?content=embed_4.html
http://blog.flexexamples.com/2007/08/07/embedding-sound-effects-in-your-Flex-applications/
If this post answers your question or assistance, please mark it as such.
Greg Lafrance
www.ChikaraDev.comSupport and Flex development services
-
How can I know what sounds or symbol is used?
Hello. Two related questions:
-Is it possible to click on something in my project - a symbol or an audio clip, I already placed in the library - and know what element of the particular library is?
-Can I play acoustics of the library window, to preview before you place them?
Thank you!
-Is it possible to click on something in my project - a symbol or an audio clip, I already placed in the library - and know what element of the particular library is?
Yes, right click and click on "view in the library.
-Can I play acoustics of the library window, to preview before you place them?
Yes, click on your sound library, then in the window of your library panel preview will be a play/pause button
-
How can I silence the sounds of HDR380cx button?
Sometimes I need to be able to use the camcorder and NOT have it make a noise whenever I have the touch screen or work in the menus. I found the setting of the volume of these sounds, but is there a way to totally STOP them?
Yes you can.
When you press Menu, you will find 6 different submenus.
Shooting mode
Camera/microphone
The image quality/size
Playback function
Edition/copy and
Installation program.Select the entire upward and then General settings. Under general settings, you will find the required setting to activate the beeps on and outside.
-
How to play my games if I can't use Flash?
Firefox has blocked Adobe Flash, so I can't access my games on Facebook, Pogo and many other sites. Is there something else we can use or download? Thank you.
Hello, adobe has released a critical patch to mitigate yet another vulnerability in his version of the flash plugin, which is apparently already exploited in the wild. That's why firefox will block the precarious versions which run by default on Web sites for your protection.
https://helpx.Adobe.com/security/products/Flash-Player/apsb15-18.htmlPlease update Adobe Flash Player version 18.0.0.209 as soon as possible, that you can download from http://www.adobe.com/products/flashplayer/distribution3.html (use the windows exe for plugin-based browsers).
-
How can I configure firefox to play a beep sound when my yahoo or gmail mails to the?
How can I configure firefox to play a beep sound when my yahoo or gmail mails to the?
Hi, you could try the add-on x - notify .
If your question is resolved by this or another answer, please take a minute to let us know. Thank you.
-
How can I get the sound card to play on the speakers of the car?
How can I get the sound card to play on the speakers of the car?
Usually connecting the phone to the car system - particularly at the point where you can play the music usually connects the Maps app
There is a switch at the bottom of the maps app with a speaker symbol that allows you to toggle between having the sound coming through the phone or Bluetooth
-
original title: help!
I downloaded a program to watch on my Media Player and when I press on play I have sound but no picture, only models. How can I get the picture?
What is the format of the video file?
If the extension is. AVI... no guarantee... but maybe
you need the XviD Codec.(FWIW... it's always a good idea to create a system)
Restore point before installing software or updates)XviD Codec
http://www.xvidmovies.com/codec/ -
How to code a button to play and pause sound using its loading?
How to code a button to play and pause sound using its loading? I used the sound load methos to fix the sound. Can someone help me?
I can't determine where the sound is defined and where you try to control it. This will work but is sloppy coding:
Stop();
adaDrut1.onRelease = function () {}
_root.mySoundC = new Sound (this);
_root.mySoundC.loadSound ("F #/ Bhajni1.ark", true);
_root.mySoundC.onSoundComplete = function() {}
This.Start (); }
gotoAndPlay ("play2");
_Global.myTaalLaya = 'entries Low1. "
}
{play_btn.onRelease = Function ()}
_root.mySoundC.start ();
}
{pause_btn.onRelease = Function ()}
_root.mySoundC.stop ();
}
-
How to play a sound on a button to the bottom of the State?
Hello
That is my question. How to play sound on CLICK or down state of the button? I don't know how to slap a sound on the timeline, but not how to put specifically for the button and that's down from the State.
Thanks for the help in advance.
go to the scenario of the button and attach a sound to its low chassis. You probably want the sync event property.
-
How to choose what program plays what, where sound?
Hi all
First of all, I don't know if this is the right topic, but I couldn't find other technical subjects or something similar.Runing windows 8 Pro and I had also a headset (USB connected) and audio (HDMI connected), but I can't select what program to play where the sound. Now, I prefer to have all the music and movies played on systems of sound and communications such as Skype, Ventrilo and Teamspeak on the helmet, which is.But when I play the games I'd allso favorite play the sound of some of the games on the helmet, but often games like the Sims 3 has played on the sound system.Is there a way to fight against this or is there some kind of software that will allow me to select what's playing where?Lawa Hi,By design, we can choose and define the different applications to play sound through the headphones and speakers of the HDMI.You can search for a third-party application that supports this feature by using your favorite search engine.Note: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.Hope this information helps. If you need more assistance or information on this question, reply to this post. I'll be happy to help you.
-
How to play music through the bluetooth earpiece/headset
Original title:
I HAVE CONNECTED MY HEADPHONE BLUEDIO AV890 WITH MY PC... BUT HOW CAN I HEAR MUSIC FORM MY PC THROUGH IT...I CANNECT THE BT HEADSET USING PASSKEY... BUT I DON'T KNOW HOW TO PLAY SONGS VIA HEADPHONE BLUETOOTH, SOMEONE CAN HELP MEHello
T
Hank you for the display of the query in the Microsoft community!
We will guide you through this issue.You receive an error message?
You can try the following steps and check if you are able to hear the music from your computer
Method 1:
You can configure Bluetooth headset as default Audio Device.
a. click Start, click run, type mmsys.cpl and then click OK.
b. click on the Audio tab.
c. in the sound playback section, select the headset and set it as your default device.Method 2:
You can update the latest drivers for the Bluetooth drivers on the manufacturer's Web site.
How to manage devices in Windows XP
http://support.Microsoft.com/kb/283658Just reply with the results. I'd be happy to help you further.
-
How to play audio through the headphones and computer speakers, at the same time.
Hey I just need to know how to play sounds through the headphones and speakers. Help
Depends on your audio device.
If its edge, while normally when you plug the headset switch will cut off the speakers.
If you have a USB or Firewire pro device you can listen to your headphones as the signal played through your speakers.
See you soon,.
Jerry -
How to play two audio tracks together?
Original title: Please give me an answer as soon as possible.
How to play two audio files.
Is English spoken numbers and another with Hindi spoken numbers. These files are read on a single system after robin its mix of figures.
How can I do?
Hello
You want to play both audio files simultaneously?
If you want to play two music files at the same time, you need to use 2 media players. You will then be able to hear the two pieces of music at the same time of the machine.
However, if you want to play the 2 files in such a way that for a moment plays English and then for a few minutes the other plays, you will need to use some sound capture software to cut clips from the original files and merge them accordingly and play.
Microsoft doesn't have any audio/video capture software. However, you can use your favorite search engine to download any software cutting.
Note: This response contains a reference to third party World Wide Web site. Microsoft provides this information as a convenience to you. Microsoft does not control these sites and no has not tested any software or information found on these sites; Therefore, Microsoft cannot make any approach to quality, security or the ability of a software or information that are there.
Hope the helps of information. Please post back and we do know.
Concerning
Joel S
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think.
Maybe you are looking for
-
After update of FF 40.0.2 three lines of the separator is appeared in "view your story. And they stay there even if the history is cleared.
-
How to fix - cartridge missing or not detected
have a photosmart c4280 all-in-one, CC210A. to get the message that the cartridges are not detected. Both are loaded correctly. I suspect that a sensor is crapped out. over time, maybe ink excessive spray? How to fix?
-
Before installing 4.0.1 I could right click on the Firefox icon in the task bar of my computer and press on the window. He would then give me the option to "save the tabs and exit" or "close all tabs".Now he comes and tells me I'm going to close seve
-
Despite more Firefox and Flash directions, Firefox can't read videos from YouTube, Hulu, etc.. They not only never load or load and freeze a few seconds. Before I got the latest versions of Firefox and Flash, I did not have this problem. So there mus
-
PCoiP: HPDM 4.6 How to deploy background logo company on Thin Clients
Can someone advise please how to deploy our customers business desktop light of 4.6 HPDM background. I try to use the file and rgistry and deploy files and I know the location to deploy files but for the last 4 hours, he sat on the shipment and wallp