Player, Basic: Play an mp3 file

140 views
Skip to first unread message

Scott Ferguson

unread,
Sep 27, 2012, 7:31:40 AM9/27/12
to

The Player component takes a supported media file and plays it.
In this exercise we will have the Player component load and play an mp3 file.

Create a new project named lrn_plr_basic.

Screen Designer:

Add the bach_jesu.mp3 asset file to the Media folder.

Change Screen1.Title to Player component demonstration.














Drag and drop a Button component onto the Viewer.
Change Button1.Text to Play.













Drag and drop a Player component onto the Viewer.
This instance of the Player component is given the default name of Player1.
Since it is a Non-viewable component it jumps to the bottom of the Viewer.
Note the bach_jesu.mp3 file that has been added to the Media list, also.
















Blocks Editor:

Drag and drop a Button1.Click event block onto the BE canvas.







Drag and snap a Player1.Source block inside Button1.Click.


















Drag and snap a text block into the Player1.Source's to socket.
Change the text value to bach_jesu.mp3.
 - this tells the Player component which file to play







Drag and snap a Player1.Start block below Player1.Source.
 - this block begins playback of the mp3 audio file








END.

That completes our simple Player app project.
Test your project in the emulator or on a connected device.
(if you don't hear any sound, check your device or computer volume level)















Challenge: What if while we are enjoying our music selection, the phone rings? Can you add a pause or stop button to the project?
lrn_plr_basic.zip
bach_jesu.mp3
Reply all
Reply to author
Forward
0 new messages