Blog
All Blog Posts | Next Post | Previous PostHardware access from TMS WEB Core apps
Wednesday, October 18, 2023
TMS WEB Core is an innovative framework designed to build web applications using Object Pascal language. Despite the primarily web-centric nature of applications built with TMS WEB Core, the framework offers a variety of components that facilitate hardware access, allowing developers to bridge the gap between web applications and physical devices.
In this article, we'll dive into the components of TMS WEB Core that enable hardware access:
Camera & microphone
The first hardware accessory that comes to mind when talking about web hardware access is the device camera. This can be the camera integrated with the smartphone you are using of the web camera connected to your desktop PC. TMS WEB Core provides a component for working with the camera. The component TWebCamera allows you to work with these cameras. It can be used for capturing still images. The TWebMediaCapture can be used to record video or just audio. When your device has multiple cameras, like a front and back camera on a smartphone, the TWebCamera allows you to select the desired camera. There are a few things to pay attention to. First of all, starting the camera unattended is (for obvious privacy reasons) not possible. The browser will typically show a prompt for the user to allow switching on the camera. On Safari, there is an additional requirement that for the camera to work, the web app should run from a HTTPS enabled domain. On an iPhone, it also requires a physical interaction with the app (like clicking a button) to have the camera switched on. That means that if you would turn on the camera in code during app startup, it will not work.
Related articles:
Use the camera for barcode scanning
Related articles:
Use the camera for barcode scanning
Touch
The touch interface of a screen is equally a separate hardware interface. In TMS WEB Core touch interaction with components is handled via events OnTouchStart, OnTouchMove, OnTouchEnd, OnTouchCancel. In this way, it is possible to have applications react differently to touch on the screen than a click via the mouse. When the application is running on a mobile device, touch events are by default mapped onto mouse events so that you do not need to separately add application logic for dealing with mouse and touch.
Screens
Detecting the number of screens attached to your device and controlling on what screen to show a browser window is these days also possible from a web application and TMS WEB Core has support for it. GetScreensInfo returns an object TJSScreenInfo that contains all information about connected screens. The method createPopup() has an extra parameter to control on what screen a new window is opened.
Related articles:
Related articles:
GPS
Mobile devices come these days all equipped with a GPS for location capturing. TMS WEB Core's TWebGeolocation component interfaces with the device's GPS or network-based positioning system, providing accurate location data. The nice thing about TWebGeolocation is that also when the device has no GPS on board, it will nicely fall back to determine the most nearby location based on network. One more small remark in connection to geo location is that the interface to capture it is asynchronous. Either you start the capture of geo location with GetGeolocation and get the actual result via event OnGetgeolocation or you use the promise GetGeolocationAsync.
Related articles:
DIY navigation with TMS WEB Core
Related articles:
DIY navigation with TMS WEB Core
Compass
For devices with a compass on board, TWebDeviceOrientation can be used to determine the orientation of the device. Use TWebDeviceOrientation.Start and each time the orientation of the device changes, the event OnHeadingChange will be triggered returning the new orientation as Heading (an angle between 0 and 360°).
Related articles:
DIY navigation with TMS WEB Core
Related articles:
DIY navigation with TMS WEB Core
USB
TMS WEB Core also has provisions to interface with the Web USB API. This API makes USB devices accessible to web applications, allowing for direct data transfers and device operations. Note that at this moment only Chrome based browsers (Chrome and Edge Chromium) fully implement the Web USB API. USB access comes in two flavors: HID and serial. As such, there are in TMS WEB Core two components: TWebUSBHID and TWebUSBSerial.
Related video:
Accessing USB HID and USB serial via TMS WEB Core
Related video:
Accessing USB HID and USB serial via TMS WEB Core
Bluetooth
The Web Bluetooth API provides an interface for connecting web applications with Bluetooth-enabled devices. TMS WEB Core integrates with this API to offer components that facilitate seamless communication between web apps and Bluetooth peripherals. Perfect for web apps that need to communicate with printers, scanners, game controllers, or even custom Bluetooth devices developed for specific enterprise applications. As with USB, it is at this moment only fully implemented in the Google Chrome and Microsoft Edge Chromium browsers.
Related articles:
Speech recognition
Browsers can now also take advantage of hardware supported speech recognition and allow you to build voice driven web applications. In TMS WEB Core, TWebSpeechRecognition allows you to take advantage of this. You basically set the language and a number of command words and each time the speech recognition detects any of these words, it will trigger the event OnResultMatch.
Related video:
Related video:
Overview
Here is a convenient overview for what hardware access is today possible in the different browsers:
Chrome | Edge | Firefox | Safari macOS | Safari iOS | Chrome Android | WebKit Linux | |
Camera | |||||||
Touch | |||||||
Screens | |||||||
GPS | |||||||
USB | |||||||
Bluetooth | |||||||
Speech recognition |
The future?
The web world is in constant change and functionality is added all the time and some more hardware access functions are already in the browser or expected soon. We at tmssoftware.com monitor this situation and where possible bring the supporting components for it. We are eager to learn what kind of additional functionality you look for!
Conclusion
In conclusion, TMS WEB Core is bridging the world of web applications and physical hardware. By leveraging the provided components, developers can craft more immersive, responsive, and powerful web applications that interact with the world in ways previously reserved for native applications. Whether you're aiming to connect to IoT devices, capture multimedia, or understand device orientation, TMS WEB Core has the tools to make it happen.
Bruno Fierens
This blog post has received 6 comments.
2. Wednesday, October 18, 2023 at 10:22:48 PM
With TMS WEB Core you do not need to install Android support in Delphi to be able to create and run TMS WEB Core apps on Android
Bruno Fierens
3. Wednesday, October 18, 2023 at 10:36:47 PM
Could you please direct me to a source where the entire process, step by step, of such a solution is described from the beginning to running it on a mobile device? (or any of the mentioned devices). Assuming solely pure collaboration between Delphi and Web Core, or TMS FNC. I assume that initially, it will involve trivial scenarios to demonstrate the real-world possibilities.?
Bal? Miroslav
4. Thursday, October 19, 2023 at 8:08:24 AM
You deploy the TMS WEB Core app on a web server and start it from the URL and when it is a PWA, Android will offer you the capability to install it on the home screen.
Bruno Fierens
5. Thursday, October 19, 2023 at 2:54:24 PM
Thank you for your response.I have read the information about PWA applications, including: ''https://www.tmssoftware.com/site/blog.asp?post=960''.
I watched a video on YouTube: ''https://www.youtube.com/watch?v=-hW-lA1UoBg'' and compiled and tested your demo application ''PWACalculator''.
I successfully installed it on my PC and also on Android (Samsung A50 mobile).
I watched a video on YouTube: ''https://www.youtube.com/watch?v=-hW-lA1UoBg'' and compiled and tested your demo application ''PWACalculator''.
I successfully installed it on my PC and also on Android (Samsung A50 mobile).
Bal? Miroslav
6. Thursday, October 19, 2023 at 2:55:46 PM
👍
Bruno Fierens
All Blog Posts | Next Post | Previous Post
"I apologize for the layman''s question. It relates to the current topic: ''TMS WEB Core.''
To run a program I create in Delphi using ''TMS WEB Core'' for an Android phone/mobile, do I need to have Android support installed in Delphi?
I could potentially install it, but that seems to be a rather complex task. Therefore, I would like to find a way to develop applications for mobile phones using only pure Delphi and TMS Web Core. If it''s possible to create a program without installing mobile support in Delphi, please direct me to a source where I should start so that I can create my first web/android application based on TMS Web Core. And how should I then run it on the specific device?"
Bal? Miroslav