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().

Tags: BlackBerry Developers

Similar Questions

  • Windows 7 is not play sounds on the Internet on Bluetooth speakers

    Windows 7 connects to Bluetooth speakers, play sounds from the computer and iTunes, but does play no sound internet radio, UTube, etc... Someone knows how to fix this? Thank you!

    Thanks for getting back to me so quickly.  The problem was not related to applications of inhibition, as my speakers would not play sound from ANY internet site whatsoever, even when the volume of the app contributed to the maximum, but he would play his wireless from iTunes and other internet applications no.  After that I restarted my computer this morning, the problem has been resolved.  I have restarted my computer several times yesterday, with no resolution.  I wonder if I got a Windows 7 update during the night which fixed the problem?

  • Impossible to cancel the order using OE_ORDER_PUB. Process_order. Help, please!

    Hi all

    I use OE_ORDER_PUB. Process_order API to cancel the order (order). The API return status is the success, but the order is not affected. I tried with several levels and with different values but failed to get the required results. Here is the code

    declare
    l_step varchar2 (250);
    l_err_msg varchar2 (1000);
    v varchar2 (1000);
    l_LINE_TBL oe_order_pub. Line_Tbl_Type;
    l_header_rec oe_order_pub. Header_Rec_Type;
    lx_return_status VARCHAR2 (10000);
    lx_msg_count NUMBER;
    lx_msg_data VARCHAR2 (10000);
    lx_header_rec oe_order_pub. Header_Rec_Type;
    lx_header_val_rec oe_order_pub. Header_Val_Rec_Type;
    lx_header_adj_tbl oe_order_pub. Header_Adj_Tbl_Type;
    lx_header_adj_val_tbl oe_order_pub. Header_Adj_Val_Tbl_Type;
    lx_header_price_att_tbl oe_order_pub. Header_Price_Att_Tbl_Type;
    lx_header_adj_att_tbl oe_order_pub. Header_Adj_Att_Tbl_Type;
    lx_header_adj_assoc_tbl oe_order_pub. Header_Adj_Assoc_Tbl_Type;
    lx_header_scredit_tbl oe_order_pub. Header_Scredit_Tbl_Type;
    lx_header_scredit_val_tbl oe_order_pub. Header_Scredit_Val_Tbl_Type;
    lx_Header_Payment_tbl oe_order_pub. Header_Payment_Tbl_Type;
    lx_Header_Payment_val_tbl oe_order_pub. Header_Payment_Val_Tbl_Type;
    lx_line_tbl oe_order_pub. Line_Tbl_Type;
    lx_line_val_tbl oe_order_pub. Line_Val_Tbl_Type;
    lx_Line_Adj_tbl oe_order_pub. Line_Adj_Tbl_Type;
    lx_Line_Adj_val_tbl oe_order_pub. Line_Adj_Val_Tbl_Type;
    lx_Line_price_Att_tbl oe_order_pub. Line_Price_Att_Tbl_Type;
    lx_Line_Adj_Att_tbl oe_order_pub. Line_Adj_Att_Tbl_Type;
    lx_Line_Adj_Assoc_tbl oe_order_pub. Line_Adj_Assoc_Tbl_Type;
    lx_Line_Scredit_tbl oe_order_pub. Line_Scredit_Tbl_Type;
    lx_Line_Scredit_val_tbl oe_order_pub. Line_Scredit_Val_Tbl_Type;
    lx_Line_Payment_tbl oe_order_pub. Line_Payment_Tbl_Type;
    lx_Line_Payment_val_tbl oe_order_pub. Line_Payment_Val_Tbl_Type;
    lx_Lot_Serial_tbl oe_order_pub. Lot_Serial_Tbl_Type;
    lx_Lot_Serial_val_tbl oe_order_pub. Lot_Serial_Val_Tbl_Type;
    lx_action_request_tbl oe_order_pub. Request_Tbl_Type;
    i the number: = 1;

    Cursor ord_det_cur (l_ord_num number) is
    Select * from oe_order_lines_all
    where header_id = (select header_id in the oe_order_headers_all where order_number = l_ord_num);

    BEGIN
    fnd_client_info.set_org_context (101);
    for ord_det_rec loop ord_det_cur (1000809635)
    If I = 1 then
    l_header_rec: = OE_ORDER_PUB. G_MISS_HEADER_REC;
    l_header_rec.flow_status_code: = "CANCELLED";
    l_header_rec.cancelled_flag: = 'Y ';
    l_header_rec.change_reason: = 1;
    l_header_rec.header_id: = ord_det_rec.header_id;
    end if;
    l_line_tbl (i): = OE_ORDER_PUB. G_MISS_LINE_REC;
    l_line_tbl (i) .ordered_quantity: = 0;
    l_line_tbl (i) .header_id: =. ord_det_rec HEADER_ID;
    l_line_tbl (i) .line_id: =. ord_det_rec LINE_ID;
    l_line_tbl (i) .cancelled_quantity: = ord_det_rec.cancelled_quantity;
    l_line_tbl (i) .flow_status_code: = "CANCELLED";
    l_line_tbl (i) .cancelled_flag: = 'Y ';
    l_line_tbl (i) .change_reason: = 1; -"Test"; -"No reason given";
    l_line_tbl (i) .operation: = OE_GLOBALS. G_OPR_UPDATE;

    i: = i + 1;
    end loop;
    dbms_output.put_line ("'start API");
    Apps.oe_order_pub. Process_Order (p_api_version_number = > 1.0
    , p_init_msg_list = > FND_API. G_TRUE
    , p_return_values = > FND_API. G_TRUE
    , p_action_commit = > FND_API. G_TRUE
    , x_return_status = > lx_return_status
    , x_msg_count = > lx_msg_count
    , x_msg_data = > lx_msg_data
    , p_header_rec = > l_header_rec
    , p_line_tbl = > l_line_tbl
    , x_header_rec = > lx_header_rec
    , x_header_val_rec = > lx_header_val_rec
    , x_Header_Adj_tbl = > lx_Header_Adj_tbl
    , x_Header_Adj_val_tbl = > lx_Header_Adj_val_tbl
    , x_Header_price_Att_tbl = > lx_Header_price_Att_tbl
    , x_Header_Adj_Att_tbl = > lx_Header_Adj_Att_tbl
    , x_Header_Adj_Assoc_tbl = > lx_Header_Adj_Assoc_tbl
    , x_Header_Scredit_tbl = > lx_Header_Scredit_tbl
    , x_Header_Scredit_val_tbl = > lx_Header_Scredit_val_tbl
    , x_Header_Payment_tbl = > lx_Header_Payment_tbl
    , x_Header_Payment_val_tbl = > lx_Header_Payment_val_tbl
    , x_line_tbl = > lx_line_tbl
    , x_line_val_tbl = > lx_line_val_tbl
    , x_Line_Adj_tbl = > lx_Line_Adj_tbl
    , x_Line_Adj_val_tbl = > lx_Line_Adj_val_tbl
    , x_Line_price_Att_tbl = > lx_Line_price_Att_tbl
    , x_Line_Adj_Att_tbl = > lx_Line_Adj_Att_tbl
    , x_Line_Adj_Assoc_tbl = > lx_Line_Adj_Assoc_tbl
    , x_Line_Scredit_tbl = > lx_Line_Scredit_tbl
    , x_Line_Scredit_val_tbl = > lx_Line_Scredit_val_tbl
    , x_Line_Payment_tbl = > lx_Line_Payment_tbl
    , x_Line_Payment_val_tbl = > lx_Line_Payment_val_tbl
    , x_Lot_Serial_tbl = > lx_Lot_Serial_tbl
    , x_Lot_Serial_val_tbl = > lx_Lot_Serial_val_tbl
    , x_action_request_tbl = > lx_action_request_tbl
    );
    dbms_output.put_line ('lx_return_status -' | lx_return_status);
    IF lx_msg_count > 0
    THEN
    dbms_output.put_line ('Listing mistakes.. .to order number')-;

    FOR l_index in 1... lx_msg_count
    LOOP
    v: = apps.oe_msg_pub.get (p_msg_index = > l_index p_encoded = > apps.fnd_api.g_false);
    dbms_output.put_line ('Listing mistakes.. .to order number-' | v);
    END LOOP;
    END IF;
    end;
    /

    Please help because it's very urgent.

    Another question: can cancel us orders in the State entry? I tried to frontend, it makes the order quantity = 0 but the order status remains in State of the input.

    Thanks in advance
    Himanshu

    Himanshu salvation,

    Instead of using l_line_tbl (i) .change_reason: = 1, in the script, please use l_line_tbl (i) .change_reason: = 'PLANT REQUEST' & test the issue again. Please check metalink Note 746797.1 for the script to cancel the order using this API.

    If the order is in a State of entry, instead of the cancellation of the order, you can remove the command using the same API.
    Please check metalink Note 746809.1 for the script delete using this API sales slip.

    Kind regards
    Jyoti

  • 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 mSoundsToPlay;

    then add the sound to play when do:

    if (mSoundsToPlay.isEmpty())
    {
      mSoundsToPlay.push_back(soundName);
      ...start playing soundName...
    }
    else
    {
      mSoundsToPlay.push_back(soundName);
    }
    

    in playbackCompleted() Manager:

    mSoundsToPlay.pop_front();
    if (!mSoundsToPlay.isEmpty())
    {
      ...play next sound from mSoundsToPlay.front()...
    }
    
  • Satellite L650 - no sound on the TV using an HDMI cable

    using a HDMI to connect to the TV picture cable works fine but no sound through the TV, sound out of speakers to computer. How can I configure so sound comes through the TV?

    Hello

    Usually it should automatically work but try it please check the settings in the sound properties > reading.
    Switch off the speakers and turn on the digital audio device (HDMI).

  • How can I get WMC to play sounds on the default device?

    I'm under WMC via HDMI to a SAMSUNG TV. Works very well, but to get a sound to play through the TV (which is in another room), change the playback by default windows to SAMSUNG device. I would like to have sound PC via the PC and only the WMC sounds via the TV.  My PC can split the sound, as with DEFAULT SAMSUNG I can go to Windows Media Player (WMP not WMC!) and the value of reading through the speakers. So has solved part of the problem, because music is now back on the PC and the TV via WMC are on TV. However, the SYSTEM SOUNDS stay with the DEFAULT device and are as such on the TV.

    The ultimate would be to have speakers as the default, and then be able to go in WMC and play through the HDMI connection on the SAMSUNG TV.  Otherwise, I need to be able to change the SOUND SYSTEM to the uncommon speakers.

    Whenever I set up through WMC speakers, he grabs SAMSUNG as the default device. If this isn't just a question of sequencing.

    Any ideas?

    Hi Tony,.

    Not sure if it is an option currently in Windows Media Center.

    However, you can post your request in the below given link and see if they can help you accomplish what you want.

    www.thegreenbutton.com/forums.

    In addition, you can leave you valuable suggestion in the below given link so that your request to change the options in the Media Center window is taken into consideration. http://mymfe.Microsoft.com/Windows%207/feedback.aspx?formid=195

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Reverse the order use current default values

    Hello

    I was working with a labview program tonight and had used the command 'Reset all default' in the menu use to clear all waveforms on my screen.  However, I accidentally chose the command "Make default current values" and can't erase what appears in the waveforms.  I'm sure there is a simple solution to my problem, but I could not understand.  I tried rewiring parts of my diagram didn't exclude graphs of waveform with the hope that the waveforms would leave but realized that the graphics were not wired so nothing would change.  Any help would be appreciated.

    Thank you

    bsteinma

    Unless you also saved, simply close the VI. If you want to save the VI, then just delete the graphics/charts by right-clicking and selecting data operations > clear chart.

  • audio files do not play sound after the restoration of the links

    I recently moved to a project from one disk to another.

    When I opened it the project folder I had to recreate a link to all the media which seemed to have a lot of success. However the audio files do not seem to play any sound. When I tell one of the audio files in the finder window, it take me for an alias file. When I try to open this file, it indicates that the original file cannot be found.

    I tried to remove the entire library of files sound and re-import them back in. But still, it does not solve this ridiculous issue.

    Any suggestions?

    Thank you

    Karl

    Are music protected audio files?

    Russ

  • Gigaframe L81 does not play sound in the videos shot by Nokia phone. Q81 can do?

    Hi all.

    My parents bought Gigaframe L81 photo frame.

    My mother tried to use the photo frame to see the videos shot by her Nokia phone. And the problem was only that no sound has been replicated by the photoframe

    AFAIK, new Nokia phones shoot videos in the following format
    Video: MPEG4 Video 640 x 480
    Audio: AAC 48000 Hz mono 768 Kbps

    When I look at Gigaframe L80 & L81 features at the stop. quote
    http://www.Toshiba.EU/PhotoFrame/detailsl80.htm
    I see that it is said in support of only Audio: MP3

    At the same time Gigaframe Q80 & Q81 claim to support more audio codecs:
    http://www.Toshiba.EU/PhotoFrame/detailsq80.htm
    Audio: MP3, AAC, OGG

    So, I have the following questions:
    (1) are Q80 & Q81 models actually higher than L80 & L81? My parents thought that L80 & L81 are better models, because they have a bigger screen. They thought that L80 & L81 should have more features. But it seems that Q80 & Q81 support more audio formats...

    (2) & Q80, Q81 don't actually support AAC & AAC in MP4 video files audio streams support?

    (3) how do I know if Toshiba will add support for AAC to L80 & L81? Or maybe my parents sell their L81 and buy Q81 or something else?
    My parents are not going to use the software that comes on the CD to convert their videos, the software first because is too difficult for them, the other reason is that it takes time to convert the videos to the formats supported by the framework, and that means that all the benefits of using an image on a PC went...

    Hello yura-v,.

    I am also a user Gigaframe L81.
    I asked the Support Toshiba team, if he releases a firmware update or something.
    They said no. Toshiba is not going to add support for AAC to L80 & L81 right now.
    If Q80 & Q81 actually support AAC & AAC audio streams support MP4 video files, I cannot say for sure, because I only own a Gigaframe L81.

    I think the best way is, your parents must buy a Q80 or 81 and test this.
    If both this doesn´t supports AAC streams they could restore the frame within 14 days.

    If they support the AAFC, they can sell their L81 framework and celebrate the Q80 or the Q81.

    Best regards

  • Media Player - how to get to play sound from the speakers

    I believe that I have can I have deleted a device to play the sound on my speakers. I just want to know how to get my speakers to stream audio again?

    Hi Margaretmac Millan,

    1. what operating system is installed on the computer?
    2. don't you make changes to the computer before the show?

    Method 1
    I suggest you to run the fixit from the following link:

    Diagnose and automatically fix the audio problems and audio playback
    http://support.Microsoft.com/mats/AudioPlayback/

    Method 2
    I suggest you try the steps from the following link:

    No sound in Windows
    http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows

    Method 3
    If the problem persists, then I suggest you to perform system restore to the date it was working fine.

    System restore
    http://Windows.Microsoft.com/en-us/Windows7/products/features/system-restore

  • No sound from the TV using a HDMI cable not connected to the laptop ASUS G75VW.

    I have an ASUS G75VW, when I connect the HDMI to my TV, I get only audio through my computer laptop speakers or headphones, while it is plugged.  In addition, the TV picture is only 480 p.  When I check the sound icon, it shows that the HDMI port is "not connected" even though it is.  I tried to uninstall and reinstall the driver on both the NVIDIA site and the site of ASUS.  Same question.  Help, please!

    Hello

    Make sure that it has the TV volume.

    You can also make sure that the connections are appropriate. Try to connect to another HDMI port as well.

    Refer to the section: "Check if the cables are connected correctly" and set the HDMI audio device as the default value.

    No sound in Windows

    I also suggest you to consult the steps mentioned by "Karthik Vengaloor responded on 14 January 2013" and perform useful methods.

    Reference:

    Windows 8 audio via hdmi on desktop cable

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-pictures/Windows-8-audio-through-a-HDMI-cable-on-desktop/79aaa786-8311-4FA2-8206-0e57b8861baf

    Hope this information helps. Response with status so that we can help you.

  • Satellite C55D - no sound on the TV using an HDMI cable.

    Hello

    When I connect my laptop via hdmi cable to the TV digital sound is heard through the speakers, but not on TV.
    It worked well before, not now.
    Everything is connected, I tested with new cables. It is set up.
    Devices, it seems that none connected.

    Help, please?

    Try to activate sound output manually in the sound properties. What entries you can see in the devices section of reading?

  • play sounds of the monitor

    I would like to turn the sound on my monitor

    Hi glyniswray,

    Follow the steps described in this document and inform if it helps.

  • Files NO LONGER play in the order: the two album songs AND Overdrive WMA Audiobook

    I have an old clip 2 GB and HAVE BEEN very happy with it.  Until recently, he was well behaved.  I have never sought or used shuffle and happily play my 'albums' (including books, audio, of course) in the order they came.

    A few months ago, my audio books (Overdrive) downloads were not play tracks in the order LONGER.  Then, I checked and found that my music albums were also playing their pieces in a random-like order.  So I guess that the Overdrive and its software is not the culprit - the problem is in my Clip.

    My video was blank (parameters had never tampered with) last week, I downloaded the latest firmware Sansa (1.01.35 as) dated 03/15/10, but that makes no difference to the nasty problem.

    Today, I reformatted (that hurt, lose all the music and books that I got in there), but reloading a known album the video is STILL to play the tracks on the album in an odd order.

    Nothing works.

    What needs to be done?

    Any help is received with gratitude!

    James,

    Thanks for your suggestion of "reset".  This caused my pieces of music to play in the original order once again!

    Now it's on to download a book from Overdrive and see how it works.

    I'll make the time where I tested it.

    JimT

  • Someone at - it an easier way to play sounds?

    I learned AS3 this year and so far the more difficult and annoying thing for me is how works the sound channel.

    I have a support of movieclip with about 20 images, with each image animation.

    I've been coding my sound effects, but soon I'll need a Voiceover track on each image. I don't want to have

    to write tons of code for each of them, play them and stop them if the user toggles back.

    Is there a simple way to do this? I tried to add sound on the timeline using 'event', but they don't stop

    play if you go to a new framework.

    Any ideas?

    Thank you

    Matt

    Yes, you can have external MP3 files, also a long time that you added the files on the general tab of the iOS parameters.

    stopAll() stop sounds going right now. You would go to the destination image, and then his event should play ok.

Maybe you are looking for

  • T420 motherboard update for Nvidia

    Hello I have a Thinkpad T420 with only the graphics card Intel HD 3000 integrated. Is it possible to install the Nvidia graphics chip/card, or do I need a new motherboard. I found the following 2 on eBay, but they are completely different. http://www

  • Average implement properly sampling frequency

    I am writing a program for the acquisition of data that reads the voltage and data current with a 3 phase generator, IE. There are 3 channels of voltage and data 3 (also represented under tension) current data channels come in my USB-6009. The wavefo

  • His system problem HP DV7

    The SOUND SYSTEM remains weak and will not strong as speakers will be. The volume of the sounds system is adjustable, but only amplitude of low volume. How can I get the sound system to match the speakers? I tried the mixer and the sound system will

  • Computer won't turn on after a Vista update. How can I fix?

    Yesterday, I tried to install a Vista update.  It was wide enough because the message says that I wouldn't be able to use my computer for about an hour.  I started the process and the left.  4hours later I returned and my computer is waiting for perm

  • disable the automatic function of left click in Vista

    I bought my gateway computer already loaded with Vista Home Premium.  This version seems to have an auto-click program whereby I let automatically click on what either my mouse flies over.  I often find myself in places if I'm not constantly aware of