RTL.PhotoWall Sample
PhotoWall is a sample application with a client-server architecture where a client application lets you take a picture and send that picture to a server application, which displays the picture.
The client application is a FireMonkey application, and the server application is available both as a VCL application and as a FireMonkey application.
Contents
Location
You can find the PhotoWall project at:
- Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to either of the following folders:
Object Pascal\RTL\Tethering\PhotoWall
Object Pascal\Multi-Device Samples\Device Sensors and Services\App Tethering\PhotoWall
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
This sample applications folder provides two server projects (FireMonkey and VCL) and a client project. The projects are designed so that you can run any number of instances of each at the same time. Many client applications may connect to the same server application, and any client application may connect to multiple server applications, as long as they are reachable using app tethering.
- Notes:
- The client application is intended for mobile platforms while the server application is only supported on desktop platforms.
- The VCL server application is only available in
Object Pascal\RTL\Tethering\PhotoWall
folder.
In the server application (DesktopWallApp or DesktopWallVCLApp) you have an empty image area that you can fill remotely with a picture using a client application.
In the client application (MainMobileApp) you have the following controls:
- An image area that shows the last picture taken and sent to a server application.
- A list of connected server applications under Select Photo Wall, and a Refresh button to refresh the list.
- A Take Photo button to take a picture to send to the server application selected from the list.
How to Use the Sample
- Navigate to the location given above and either one of the server applications in any of the locations given above:
- DesktopWall\DesktopWallApp.dproj
- DesktopWall\DesktopWallApp.cbproj
- DesktopWallVCL\DesktopWallVCLApp.dproj
- DesktopWallVCL\DesktopWallVCLApp.cbproj
- Select Run > Run to run the selected server application.
- On the Projects Window:
- Right-click the project group entry.
- Select Add Existing Project.
- Open either Mobile\MobilePhotoApp.dproj or Mobile\MobilePhotoApp.cbproj in any of the locations given above.
- Select Run > Run to run the client application.
Files
Each application in the project group contains a single source file that contains the class for the main form of the application.
Classes
Each application defines a single class that implements the main form of the application.
Implementation
FireMonkey Server Application
MediaReceiverManager.Password
is "1234".MediaReceiverProfile
:Manager
isMediaReceiverManager
.Text
is "MediaReceiverApp".OnResourceReceived
is handled byMediaReceiverProfileResourceReceived
, which loads theValue
of the received remote resource into the image area.
VCL Server Application
VCLMediaReceiver.Password
is "1234".VCLMediaReceiverApp
:Manager
isVCLMediaReceiver
.Text
is "VCLMediaReceiverApp".OnResourceReceived
is handled byVCLMediaReceiverAppResourceReceived
, which loads theValue
of the received remote resource into the image area.
FireMonkey Client Application
- The application defines the following methods:
CheckPhotoWalls
returnsTrue
if there is an item selected inlbWalls
. If there is no selected item,CheckPhotoWalls
returnsFalse
and shows a message.SendImage
sends a previously-taken picture, or shows a message asking you to take a picture first.FindWalls
clearslbWalls
and callsTakePhotoManager.DiscoverManagers
.TakePhotoManager.DiscoverManagers
eventually triggersTakePhotoManagerEndManagersDiscovery
.
- The application defines the following event handlers:
- If
CheckPhotoWalls
returnsTrue
,lbWallsClick
connects to the remote profile selected inlbWalls
and callsSendImage
. BtRefreshClick
callsFindWalls
.TakePhotoManagerEndManagersDiscovery
attempts to pair with any remote manager, and if successful triggersTakePhotoManagerEndProfilesDiscovery
.TakePhotoManagerEndProfilesDiscovery
:- Clears
lbWalls
. - If there is a discovered remote profile with "MediaReceiverApp" or "VCLMediaReceiverApp" as description, adds the profile to
lbWalls
. - If
lbWalls
is not empty, selects the first remote profile in the the list and connects to it.
- Clears
TakePhotoManagerRequestManagerPassword
provides the password of the remote server application: "1234".TakePhotoFromCameraAction1DidFinishTaking
loads the taken image into the image area and callsSendImage
ifCheckPhotoWalls
returnsTrue
.
- If
- The application defines the following nonvisual components:
acActions
definesTakePhotoFromCameraAction1
. TheOnDidFinishTaking
event ofTakePhotoFromCameraAction1
is handled byTakePhotoFromCameraAction1DidFinishTaking
.TakePhotoManager
:OnEndManagersDiscovery
is handled byTakePhotoManagerEndManagersDiscovery
.OnEndProfilesDiscovery
is handled byTakePhotoManagerEndProfilesDiscovery
.OnRequestManagerPassword
is handled byTakePhotoManagerRequestManagerPassword
.
TakePhotoAppProfile
:Manager
isTakePhotoManager
.
- The application defines the following controls:
Uses
- System.Tether.AppProfile.TTetheringAppProfile
- System.Tether.AppProfile.TTetheringAppProfile.Connect
- System.Tether.AppProfile.TTetheringAppProfile.Manager
- System.Tether.AppProfile.TTetheringAppProfile.OnResourceReceived
- System.Tether.AppProfile.TTetheringAppProfile.SendStream
- System.Tether.AppProfile.TTetheringAppProfile.Text
- System.Tether.Manager.TTetheringManager
- System.Tether.Manager.TTetheringManager.DiscoverManagers
- System.Tether.Manager.TTetheringManager.OnEndManagersDiscovery
- System.Tether.Manager.TTetheringManager.OnEndProfilesDiscovery
- System.Tether.Manager.TTetheringManager.OnRequestManagerPassword
- System.Tether.Manager.TTetheringManager.PairManager
- System.Tether.Manager.TTetheringManager.Password
- FMX.MediaLibrary.Actions.TTakePhotoFromCameraAction
- FMX.MediaLibrary.Actions.TTakePhotoFromCameraAction.OnDidFinishTaking
See Also
- System.Tether unit
- BDShoppingList sample
- DesktopCast sample
- MediaPlayer sample