Podcast Streaming - FireMonkey Demo

Posted by on in Programming

Jim McKeeth just relaunched his weekly Delphi podcast with Nick Hodges. Today, I thought I would show you how to build a FireMonkey app for streaming your podcast.

Visual Controls

Application Title:

  • TToolbar
    • TLabel: StyleLookUp = toollabel; Align = Contents

 

Streaming Controls:

  • TToolbar
    • TEdit: Align = Left; Margins Right = 5
    • TButton: StyleLookUp = stoptoolbutton; Margins Right = 5, Margins Left = 5;
    • TButton: StyleLookUp = playtoolbutton; Margins Right = 5, Margins Left = 5;

 

I also added a TImage for the background image and a TLabel underneath the image for the podcast title.

 

Non-Visual Controls

  • TMediaPlayer
  • TStyleBook: For this demo, I selected the following Windows 10 style which is part of Berlin Anniversary Edition: Windows10ModernSlateGray

 

Here's the code for the sample application:

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Media,
  FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit, FMX.ScrollBox, FMX.Objects;

type
  TForm1 = class(TForm)
    btnPlay: TButton;
    MediaPlayer1: TMediaPlayer;
    Edit1: TEdit;
    btnStop: TButton;
    ToolBar1: TToolBar;
    Label1: TLabel;
    ToolBar2: TToolBar;
    Image1: TImage;
    Label2: TLabel;
    StyleBook1: TStyleBook;
    procedure btnPlayClick(Sender: TObject);
    procedure btnStopClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}
{$R *.iPhone47in.fmx IOS}

procedure TForm1.btnPlayClick(Sender: TObject);
begin
  MediaPlayer1.Stop;
    begin
      MediaPlayer1.FileName := Edit1.Text;
      MediaPlayer1.Volume := 100;
      MediaPlayer1.Play;
    end;
  end;

procedure TForm1.btnStopClick(Sender: TObject);
begin
  MediaPlayer1.Stop;
end;
end.

 

 


 
 


About
Gold User, Rank: 5, Points: 558
Senior Product Manager, RAD Studio

Comments

Check out more tips and tricks in this development video: