You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-11-23 21:34:53 +02:00
Update to CEF 81.2.24
- Added code comments to the MediaRouter demo - Added a Lazarus version of the MediaRouter demo
This commit is contained in:
@@ -72,7 +72,6 @@ type
|
||||
CreateRouteBtn: TButton;
|
||||
CentralPnl: TPanel;
|
||||
SourcePnl: TPanel;
|
||||
SourceURNEdt: TEdit;
|
||||
SourceLblPnl: TPanel;
|
||||
SourceURNLbl: TLabel;
|
||||
RoutesGbx: TGroupBox;
|
||||
@@ -90,6 +89,7 @@ type
|
||||
NotifyRoutesBtn: TButton;
|
||||
ClearLogPnl: TPanel;
|
||||
ClearLogBtn: TButton;
|
||||
SourceURNCbx: TComboBox;
|
||||
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@@ -115,6 +115,7 @@ type
|
||||
procedure NotifyRoutesBtnClick(Sender: TObject);
|
||||
procedure ClearLogBtnClick(Sender: TObject);
|
||||
procedure MessageMemChange(Sender: TObject);
|
||||
procedure RoutesLbxClick(Sender: TObject);
|
||||
|
||||
protected
|
||||
// Variables to control when can we destroy the form safely
|
||||
@@ -162,16 +163,63 @@ uses
|
||||
{$ENDIF}
|
||||
uCEFMiscFunctions;
|
||||
|
||||
// This demo can use a MediaRouter to communicate with devices on the local
|
||||
// network via the CAST and DIAL protocols.
|
||||
|
||||
// TChromium exposes all the ICefMediaObserver events and the ICefMediaRouter
|
||||
// methods to show the available devices, to established communication routes
|
||||
// and to send messages to those devices.
|
||||
|
||||
// Follow these steps to test this demo :
|
||||
|
||||
// STEP 1
|
||||
// ------
|
||||
// Turn on your ChromeCast receiver. It can be an Android TV or similar device
|
||||
// like a Xiaomi MiBox. It must be on the same local network as the computer
|
||||
// running this demo.
|
||||
|
||||
// STEP 2
|
||||
// ------
|
||||
// Run this demo and wait a few seconds. It will show all the available devices
|
||||
// in the local network and the protocol used to communicate with them.
|
||||
// In the case of the MiBox device it shows a DIAL and a CAST "sink" but after
|
||||
// a couple of secods the list is updated and it only shows the CAST sink.
|
||||
|
||||
// STEP 3
|
||||
// ------
|
||||
// Select the CAST sink and click on the "Create route" button. This button will
|
||||
// use the "Source URN" value to create the route and that value has a CAST URN
|
||||
// with the "Application ID" of the "Default Media Receiver", which is CC1AD845.
|
||||
// This ID can be used for tests.
|
||||
|
||||
// STEP 4
|
||||
// ------
|
||||
// The "Established routes" box will show the routes that you created.
|
||||
|
||||
// STEP 5
|
||||
// ------
|
||||
// Select the route, type the message and click on the "Send message" button.
|
||||
|
||||
// STEP 6
|
||||
// ------
|
||||
// Click on the "Terminate route" button.
|
||||
|
||||
// WARNING
|
||||
// =======
|
||||
// This demo has a known bug when you close the form and it will crash.
|
||||
|
||||
// References :
|
||||
// ============
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/2900/add-mediarouter-support-for-cast-receiver
|
||||
// https://blog.oakbits.com/google-cast-protocol-overview.html
|
||||
// https://developers.google.com/cast/docs/developers
|
||||
// https://gist.github.com/jloutsenhizer/8855258
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.LogFile := 'debug.log';
|
||||
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO; //LOGSEVERITY_VERBOSE;
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'c:\cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'c:\cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'c:\cef\locales';
|
||||
}
|
||||
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
|
||||
end;
|
||||
|
||||
procedure TMediaRouterFrm.Chromium1AfterCreated(Sender: TObject;
|
||||
@@ -411,6 +459,8 @@ begin
|
||||
if (FLog <> nil) and (FLog.Count > 0) then
|
||||
begin
|
||||
LogMem.Lines.AddStrings(FLog);
|
||||
LogMem.SelLength := 0;
|
||||
LogMem.SelStart := Length(LogMem.Text);
|
||||
FLog.Clear;
|
||||
end;
|
||||
finally
|
||||
@@ -427,6 +477,11 @@ begin
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TMediaRouterFrm.RoutesLbxClick(Sender: TObject);
|
||||
begin
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TMediaRouterFrm.RefreshRoutesMsg(var aMessage : TMessage);
|
||||
begin
|
||||
if FClosing then exit;
|
||||
@@ -572,7 +627,7 @@ var
|
||||
TempURN, TempErrorMsg : string;
|
||||
TempSource : ICefMediaSource;
|
||||
begin
|
||||
TempURN := trim(SourceURNEdt.Text);
|
||||
TempURN := trim(SourceURNCbx.Text);
|
||||
|
||||
if (length(TempURN) = 0) then
|
||||
begin
|
||||
@@ -619,6 +674,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
TempSource := nil;
|
||||
FMediaCS.Release;
|
||||
if (length(TempErrorMsg) > 0) then AddLogEntry(TempErrorMsg);
|
||||
end;
|
||||
@@ -682,7 +738,7 @@ begin
|
||||
(length(trim(MessageMem.Lines.Text)) > 0);
|
||||
|
||||
CreateRouteBtn.Enabled := not(TerminateRouteBtn.Enabled) and
|
||||
(length(trim(SourceURNEdt.Text)) > 0) and
|
||||
(length(trim(SourceURNCbx.Text)) > 0) and
|
||||
(SinksLbx.ItemIndex >= 0) and
|
||||
(SinksLbx.Items.Count > 0);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user