« Background Color for … | Home | 20 year party moved t… »

News from the MBS Xojo Plugins Version 20.1


In this article I want to introduce you the new functionalities from the MBS Xojo Plugins in version 20.1.

Data from Images
The classes JPEGImporterMBS, GMImageMBS and GM16ImageMBS got the new property ExifThumbnail. This property extracts an embedded thumbnail in EXIF data and return it as a string. With this string we can use the method getData method of the Picture class or our JPEG functions to decompress and display the thumbnail.

The class JPEGImporterMBS got the ExifOrientation property that queries the orientation from the Exif data. We receive the orientation as an integer and you can use this number to determine and adjust the alignment if necessary.

The classes GMImageMBS and GM16ImageMBS include the new shared method FontMap. We can use this method to find out which fonts are currently available. The method can also help us to debug and find out the reason why a font is not loaded. The function returns a string with a XML structure.

Timecode for Audio (LTC)
If audio streams need to be synchronized, you usually use time codes embedded in the audio. With the LTC library, we now provide classes that can decode and encode time code for audio streams

Port audio Stream
In the plugin we have classes to use the open source PortAudio library in Xojo. To make it easier to use, we added the read and write methods to the PortAudioStreamBaseMBS class. For buffered streams this may help to easier send/receive audio samples.

JavaScript
In the last version of the MBS Xojo Plugins we introduce the JavaScriptEngineMBS class which allows you to execute JavaScript code in your projects. Now we extended the class with some new methods and properties.

You can run JavaScript functions in several threads. For this we use the “CallFunctionMT” method. The work is performed in a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. It must be called in a Xojo thread to enjoy the benefits. If it is called in the main thread it will be blocking, but keeps other background threads running. The parameters passed to the function are automatically adjusted by the function, i.e. if a function expects more parameters, undefined values are used to fill up. If more parameters are passed, additional ones are dropped

It is possible to execute JavaScript code directly in threads using the "EvaluateMT" method. Just pass a piece of JavaScript code and evaluate it thread friendly.



The method “Now” returns us the count of milliseconds since the 1st January 1970. So we can determine the current time in combination with the “TimeToDateComponents” method. This function returns us a timestamp with the format YYYY-MM-DD HH:MM:SS. Here you see the script to query the current time.

Dim j As New JavaScriptEngineMBS

Dim t As Double = j.Now
Dim d1 As JavaScriptDateComponentsMBS = j.TimeToDateComponents(t)
Dim s1 As String = d1.SQLDateTime

MsgBox str(s1)

If you want to transform a date in that millisecond format you can set the date as an object of the new JavaScriptDateComponentsMBS class. That can looks like that:

Dim js As New JavaScriptEngineMBS

Dim Date As New JavaScriptDateComponentsMBS
Date.Year = 1992
Date.Month = 07
Date.day = 15

MsgBox " Time: " + Str(js.DateComponentsToTime(date))

We have also added counting properties that query the the number of objects and global strings. In an empty JavaScript environment there are already about 1000 strings and about 400 objects. So if you want to find out how many objects and strings are added, you have to subtract the base amounts.

New functions for Mac users
The MBS Xojo Plugins in version 10.1 offers some more new features for Mac users:

NSCalendar enhancements
Further enhancements are available for Apple Calendar. With the method “dateFromComponents” from the “NSCalendarMBS” class we transform a “NSDateComponetsMBS” to a date. With the method “dateByAddingComponents” we add date components that’s are defined as NSDateComponetsMBS object. For example we have the date 07-15-1992 as date we can save it in a NSDateComponentsMBS object and transform it with ”dateFromComponents” to a date. Then I want to add 16 years to that date. Because that I need a second instance of the NSDateComponentsMBS class with a property year with the value 16. Then we add the years with the “dateByAddingComponents” method. The code you can looks like that.

Dim comp As New NSDateComponentsMBS
comp.day = 15
comp.month = 7
comp.year = 1992

Dim year As New NSDateComponentsMBS
year.year = 16

Dim cal As New NSCalendarMBS
Dim z As Date = cal.dateFromComponents(comp)
Dim sweetsixteen As Date = cal.dateByAddingComponents(year, z)
MsgBox str(sweetsixteen)

There is another method called "isValidDateInCalendar" from the NSDateComponentsMBS class. With this method you can check if there exists a calendar entry with the combined properties of the NSDateComponents object.

Webkit 2
We have a new class “WKHTTPCookieStoreMBS” that manages the HTTP cookies associated with a particular “WKWebsiteDataStore”. You can use the class e.g. to create an array of all cookies and then read them one by one via their indexes.

Example code:

Dim CookieStore As WKHTTPCookieStoreMBS = WKWebViewControlMBS1.WKWebView.HTTPCookieStore
Dim cookies() As NSHTTPCookieMBS = CookieStore.AllCookies
Dim cookie As NSHTTPCookieMBS = cookies(0)

An other new class is the WKPreferencesMBS class. The objects from this class encapsulates the preference settings for a web view. The preferences object associated with a web view is specified by its web view configuration. You can allow the use of Java and JavaScript code and make settings such as minimum font size.

The objects of the WKWebViewConfigurationMBS class supply a collection of properties used to initialize a web view. With this class you can determine how soon a webpage is rendered, how media playback is handled, the granularity of items that the user can select and many other options.

News from the AVFoundation
We support functionalities for Apple's latest audio/video framework for recording and playback. In the latest version of the plugins we have added a great AVRouteDetectorMBS which allows you to detects the presences of media playback routes. When route detection is enabled, AVRouteDetector reports whether multiple playback routes have been detected. Belonging to this class there is a control that displays controls for picking playback routes. By default, route detection is disabled. For this functionality you need Mac MacOS 10.15 or newer.


News from the topic MIDI
The new properties from the topic MIDI in the class “MidiThruConnectionParamsMBS” set the maximum (“HighVelocity”) and minimum velocity (“LowVelocity”). All events with a velocity outside this range will be filtered.

New functionalities for Windows users
Last but not least I want to introduce the new functionalities for Windows users.

News from the Navigation
Also new are the WinFileDialogMBS class. With this class you can set set options for an open and save dialog.
The WinFileDialogMBS class acting as the super class of the WinFileOpenDialogMBS and the WinFileSaveDialogMBS class. Both classes have events, properties and methods that’s are special for their needs.
With the new class WinFileTypeMBS we can define that only files with a certain data type can be opened. A script can then look like this:

Dim d As WinFileOpenDialogMBS

Dim FileTypes() As WinFileTypeMBS

FileTypes.Append New WinFileTypeMBS("JPEG image", "*.jpg")
FileTypes.Append New WinFileTypeMBS("PNG image", "*.png")
FileTypes.Append New WinFileTypeMBS("Tiff image", "*.tif;*.tiff")

d.SetFileTypes FileTypes

Additionally new are the classes WinShellItemMBS and WinShellItemArrayMBS which can handle one or more shell elements. The items in the WinShellItemArrayMBS class contains single WinShellItemMBS objects. With these you can read data, create thumbnails or compare items.



New features from the HTMLViewer for Windows
With the new method “Navigate” from the class IEWebBrowserMBS you can Navigate to a resource identified by a URL or to a file identified by a full path.

MFPMediaPlayer loop
The topic Windows Media Foundation Player that was added in the last version plays audio and video in your applications background under windows OS. In this version we have added a new feature to this component. You can use the “Looping” method from the “MFPMediaPlayerMBS” class to set whether, the content of the player should be repeated automatically. You can enable and disable this loop.

We hope you will also find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins Version 20.1. If you need a license or have any questions, please contact us.
By Stefanie Juchmes
17 03 20 - 16:57