Quantcast
Channel: Planet Object Pascal
Viewing all 1725 articles
Browse latest View live

DelphiTools.info: DWScript news roundup for June 2013

$
0
0
Here is a summary of recent changes, language highlights are initial support for sets and a new Sort() method for dynamic arrays. Apart form Linq & LLVM libraries which were previously mentioned, Brian Frost made multiple updates to the IDE Dialog. There were numerous other minor fixes and improvements, related to stability, performance and compatibility [...]

Firebird News: Hopper v1.3.0 – stored procedure/trigger debugger – released

$
0
0
Upscene Productions announces a new release of: “Hopper – a Stored Code Debugger” Hopper is a Stored Routine and Trigger Debugger, available for Firebird, InterBase and MySQL. For more information and a trial download, see the news @ Upscene Productions, pricing information is available. Bugfixes include, but not limited to: possible “data type not supported” [...]

Andy's Blog and Tools: JCL and JVCL have completed the move to GitHub

$
0
0

Both the JEDI Code Library and the JEDI Visual Component Library completed their move from Sourceforge to GitHub. The SubVersion repositories on Sourceforge are deleted/will be deleted soon.

If you want to use the JCL and JVCL with RAD Studio XE4, you need to clone/download the JCL and JVCL from GitHub. There is no official release for XE4. Further instruction on how to get the XE4 version can be seen in the readme.md file that both projects show on their GitHub page.

JCL : https://github.com/project-jedi/jcl
JVCL: https://github.com/project-jedi/jvcl

Side note: The JVCL doesn’t contain the jvcl\common\jedi\jedi.inc file anymore because it has a dependency on the JCL and that one already has the jedi\jedi.inc file as a submodule.

The Wiert Corner - irregular stream of stuff: jpluimers

It's a blong, blong, blong road...: ‘Dynamic’ Delphi/C++ samples on SourceForge via Subversion

$
0
0

Many of you will have already bumped into this information, but I’m posting it for the benefit of those who haven’t come across it.

In much the same way as how the static RAD Studio online documentation is complemented by updatable and updated web-based documentation at http://docwiki.embarcadero.com, the sample applications supplied with RAD Studio are also updated over time and available via an online Subversion repository hosted at SourceForge.

The RAD Studio Demo Code Web Site is at http://radstudiodemos.sourceforge.net and the SourceForge project page is http://sourceforge.net/projects/radstudiodemos. To pull down the demos you can use your favourite Subversion client and use the checkout functionality.

With regard to Subversion clients I like using TortoiseSVN from within Windows Explorer, although there is also a TortoiseSVN plug-in for the RAD Studio IDE. Of course if you use Delphi XE or later you can perhaps more sensibly just use the built-in RAD Studio IDE Subversion support.

Suitable Subversion repository URLs for the RAD Studio demo projects include:

From time to time you can again use your Subversion client to update the demos to take advantage of any changes made in the online repository. It’s good to be kept up to date!

Above I touched on the online up-to-date documentation. For completeness I should mention that the docwiki is available from Delphi’s Help menu (RAD Studio Docwiki) and I should also offer up this list of entry pages to the online help systems:

Finally, it’s always nice to get a refresher on what’s been added in recent product releases, so do stop by the What Was New In Past Releases page on the docwiki.

Salt Lake City Delphi Users Group: XE4 World Tour

$
0
0
RAD Studio XE4 in Action LIVE!
Salt Lake City, UT
Tuesday, June 18, 2013 @ 6:30-8:30PM
Taylorsville Library, Salt Lake City, UT

Welcome to this RAD Studio event focusing on iOS development.
RAD Studio is the multi-device, true native app development platform for everyone who needs to develop apps for desktops, tablets and smartphones, and get them to market fast. You will see how you can manage one codebase, one team, and one schedule without sacrificing performance. True native apps give you faster applications with more control, tighter security and a better user experience.
This presentation is organized by Embarcadero and will focus on:
  • Multi-device, true native application development from a single codebase for iOS, Windows and Mac.
  • Reduce complexity and cost with just one of everything for your app development: one dev team, one codebase, one budget, one schedule.
  • Be fast to market with extendable and reusable visual component building blocks for faster and highly maintainable development
Please Register Here:
http://forms.embarcadero.com/AMUSCA1306RADXE4Tour-SaltLakeCity

twm’s blog: Using dBase

$
0
0

I recently needed to do some table manipulation with Visual dBase. Not being an expert with this program (I usually write tools for that purpose in Delphi using the BDE or tdbf), I had to look up quite a few commands.

Here are the links that proved useful:

But what I was actually looking for did not show up in a Google search:

How do I replace a field in all records with the corresponding record number multiplied with 10? And this only for those records that do not have a value > 99999 in that field already.

The answer turned out to be rather simple:

goto top
replace lfdnummer with recno()*10 while lfdnummer  10000

twm’s blog: Comparing .po files with BeyondCompare

$
0
0

BeyondCompare from Scooter Software is a very versatile directory and file comparison tool. It allows filters for binary formats, weighting lines and defining a grammar for comparing text files. This is a simple grammar for .po files (used by GNUGetText):

Comment=Text matching ^# and next 0 lines

After defining this grammar, all changes in lines starting with an “#” are considered comments and therefore “unimportant differences” which can be ignored using the “ignore unimportant differences” option in the View menu.


DelphiTools.info: TMonitor vs TRTLCriticalSection

$
0
0
In this new episode of the TMonitor saga is a comparison of its locking features vs TRTLCriticalSection, aka the OS-supported critical section mechanism. Is it fair? is it fast? Fairness means that if you have several threads attempting to lock the same resources, they’ll all get a chance and none of them gets the lion’s share. [...]

Andy's Blog and Tools: DDevExtensions 2.7 for 2009-XE4 released

$
0
0

After almost a year a new version of DDevExtensions is available. It not only adds support for RAD Studio XE4 but also some new features and improves already existing functionality.

A full description of all 2.7 features can be found in the DDevExtensions Features.pdf.

What’s new

  • You can now invoke “Find Declaration” by pressing Ctrl+Alt+PgUp.
  • Shift+Ctrl+Alt+Up/Down moves a line or the selected block up/down.
  • The compile progress is also shown in the taskbar (Windows 7 or newer) and becomes yellow if there are warnings or red if there are errors.
  • The reload file dialog is replaces by one that lists all files in one list instead of asking for every file. It also supports diff-ing between the editor content and the file on disk.
  • Start Parameters toolbar (right click on the IDE toolbar and select “Start Parameter”, then right click on the appeared ComboBox to create a *.params sample file)
  • Option to release the compiler’s unit cache for already compiled projects to prevent out of memory exceptions if you compile a larger project group.

Download

NameIDE VersionFileSizeDownloadsAdded
DDevExtensions 1.615-2007DDevExtensions161Setup.zip734.07 KB14290 times 2009-01-10
DDevExtensions 2.7 FeaturesPDFDDevExtensionsFeatures.pdf595.28 KB350 times 2013-06-06
DDevExtensions 2.47, 2007DDevExtensions24Setup7_2007.zip535.41 KB4831 times 2011-07-25
DDevExtensions 2.72009-XE4DDevExtensions27.7z740.81 KB390 times 2013-06-06

 

 

Changelog

  • Added: Start Parameters ComboBox context menu to create and edit the *.params files.
  • Added: Reload file dialog replacement with diff-tool binding (one dialog for all modified files)
  • Added: Option to release compiler unit cache for all other projects when compiling a project
  • Added: Compile progress is shown in the Taskbar (Win 7+) with error and warning state
  • Added: Shift+Ctrl+Alt+Up/Down moves the current line or block up/down
  • Added: Ctrl+Alt+PgUp invokes “Find Declaration”
  • Added: XE4 support
  • Improved: “Set VersionInfo” dialog
  • Improved: More greedy filename pattern matching for “Use Unit” dialog replacement
  • Fixed: Use Unit replacement dialog didn’t show units that were in paths with $(Platform)
  • Fixed: Code Parser couldn’t handle non-ASCII identifiers
  • Fixed: All DDevExtensions versions 2009+ were debug builds instead of a release builds (D2007: “Configuration=Release” vs. D2009+: “Config=Release”)
  • Fixed: “Open file at cursor” replacement path list didn’t use XE2+’s current project’s platform library and browsing paths

Andy's Blog and Tools: IDE Fix Pack 5.3 for 2009-XE4 released

$
0
0

IDE Fix Pack is a collection of unofficial bug fixes and performance optimizations for the RAD Studio IDE, Win32/64 compiler and Win32 debugger. All patching is done in memory so that no file on disk is changed.

IDE Fix Pack 5.3 comes with many new patches for IDE bugs and compiler performance bottle necks.

New bug fixes:

The IDE sometimes disables the editor’s undo system to do some text extractions. In combination with a disabled “Keep trailing blanks” and/or an active “Optimal fill” this could cause the undo system to become out of sync with the editor content. IDE Fix Pack turns on/off those options when undo is temporarily disabled so that no unexpected automatic editor buffer changes happen. Especially Delphi 2009 is affected by this, newer versions fixed (almost?) all of these gaps.

(QC 105642) Another editor bug fix is that if you have a disabled “Keep trailing blanks” and you selected some forced blanks after the line end you got garbage bytes copied into the clipboard if you pressed Ctrl+C.

(QC 105668) Starting with XE3 the last line of a multi-line comment wasn’t repainted if you added or removed the comment’s begin token.

(QC 116373) The Designer guidelines in XE4 were spanning to the IDE’s main form instead of the (embedded) designer form. IDE Fix Pack reverts this back to XE3’s behavior.

(QC 116290) When Unit Scopes were introduced in XE2 the Code Completion wasn’t updated properly. It failed to find WM* message handlers when invoked in a TWinControl derived class if you had “Messages” instead of “WinApi.Messages” in the uses list.

(QC 115248) The Debugger leaked memory during a debug session if you had items in the Watch or Local variables list. Especially if those were types that required large chunks of memory. The memory was released after the debugged process was terminated but it could lead to an out of memory error if you had a long debug session. And it made stepping slower and slower with every step.

(QC 116008) If you had ErrorInsight active and you just compiled a project and pressed F9 (run) the project was compiled again before starting the application. This was due to the fact that ErrorInsight uses the exact same compiler instance that the compile dialog uses to compile the project. And the moment ErrorInsight started parsing the code, it set a “modified after compile” flag what caused the recompile. IDE Fix Pack prohibits that flag if the compiler doesn’t do a real compile (because the units are already compiled and didn’t change).

(QC 111500) The debugger truncated the project’s command line parameters after 1024 chars. This was caused by the usage of wsprintfA() that only supports 1024 chars.

The IDE used the old Windows XP directory select dialog that is now replaced by the Windows Vista FileOpenDialog in folder mode if the operating system is Windows Vista or newer.

The directory selection dialogs in the IDE Options and the Project Options dialogs didn’t recognize the $(Platform) and $(Config) macros and if you pressed the “Delete invalid paths” button, important directories were gone. With this patch these macros are context dependent available. If you switch the “Platform” ComboBox in the global IDE option dialog, the $(Platform) macro will be resolve to that platform. The same goes for the Project Options dialog which also resolves the $(Config) macro to the selection in the “Configuration” ComboBox.

New performance optimizations:

Opening forms that do not use LiveBindings but contain many components (e.g. TField) were slowed down by the LiveBindings packages. The patched code turned the 10 seconds from the sample project into less than 1 second.

The TStream.WriteBuffer/ReadBuffer changes that were done in XE3 to harm performance (unnecessarily copying buffer to another buffer) are undone by IDE Fix Pack for the IDE process to get the DFM streaming performance for the IDE and the linker back to normal.

RAD Studio 2009-XE2’s Pos function wasn’t the fastest. It is replaces with a faster version what should get the IDE some slight performance improvements.

The compiler performance (Win32/Win64) for code that heavily uses Generics will be a lot faster.

The XE3 Win64 compiler has a memory leak that was fixed by XE4, but for those that are still on XE3 this bug is now fixed what also makes the compilation a lot faster.

The C++ Win32 Compiler compiler got some slight performance optimization for string comparisons.

Help Insight in XE and XE2 did some unnecessary slow COM round trips between the IDE and the .NET parser code. This issue was fixed by XE3 and now it is also fixed for XE and XE2.

Downloads

NameIDE VersionFileSizeDownloadsAdded
IDE Fix Pack 5.3 for 20092009IDEFixPack2009Reg53.zip169.52 KB1 times 2013-06-07
IDE Fix Pack 5.3 for 20102010IDEFixPack2010Reg53.zip155.56 KB2 times 2013-06-07
IDE Fix Pack 5.3 for XEXEIDEFixPackXEReg53.zip144.64 KB5 times 2013-06-07
IDE Fix Pack 5.3 for XE2+UP4+Hotfix1XE2+UP4+HF1IDEFixPackXE2Reg53.zip210.66 KB3 times 2013-06-07
IDE Fix Pack 5.3 for XE3XE3IDEFixPackXE3Reg53.zip206.45 KB5 times 2013-06-07
IDE Fix Pack 5.3 for XE4XE4IDEFixPackXE4Reg53.zip206.12 KB5 times 2013-06-07

Changelog

  • Added: Fix for not disappearing Designer Guidelines
  • Added: Editor Buffer now always disables the automatic/implicit changes to the buffer if undo is disabled. Undo buffer stays in sync with editor buffer (especially in Delphi 2009)
  • Added: Fix for QC 105642: Ctrl+C causes premature line cut and garbage in the clipboard
  • Added: Fix for QC 105668: Last line of the multi-line comment is not repainted (XE3-XE4)
  • Added: Fix for QC 116373: VCL Designer Guidelines spanning to the IDE’s main form instead of the designer form. Revert to X3 behavior. (XE4)
  • Added: Fix for QC 116290: Code Completion in class declaration doesn’t find message handlers if Messages is not included by using WinApi.Messages (XE2-XE4)
  • Added: Some slight C++Builder Kibitz/Compiler performance optimization
  • Added: Faster Unicode Pos function (2009-XE2)
  • Added: XP SelectDirectory dialog replaced by Vista version if available
  • Added: Fix for QC 116169: Slow opening forms in IDE that don’t use LiveBindings (XE3-XE4)
  • Added: Fix for QC 115248: Huge memory leak in BDS.EXE with large local variables or watches (XE-XE4)
  • Added: Performance optimization for IOTAxxxx.AddNotifier where Add/RemoveNotifier is called for many items
  • Added: Fix for QC 116008: IDE always does the compile->link cycle even if there where no modifications made to the project
  • Added: Directory selection dialogs in IDE Options and Project Options use the $(Platform) and $(Config) from the option dialog (XE2-XE4)
  • Added: TStream.WriteBuffer/ReadBuffer performance optimization (DFM streaming) (XE3-XE4)
  • Added: Memory leak fix for Win64 compiler (XE3)
  • Added: Compiler performance optimization for many Generics (XE-XE4)
  • Added: HelpInsight performance optimization (XE/XE2)
  • Added: HelpInsight background WaitFor bugfix
  • Added: Fix for QC 111500: Debugger truncates command line
  • Rewritten: Linker I/O buffer memory handling
  • Improved: comp32x.dll isn’t loaded at IDE startup anymore (XE-XE4)
  • Improved: IDEFixPackReg*.exe supports command line parameters (see “IDEFixPackReg*.exe /?”)

The Wiert Corner - irregular stream of stuff: jpluimers

Firebird News: Database .NET 8.6 released

$
0
0
Database .NET is an innovative, powerful and intuitive multiple database management tool. You can Browse objects, Design tables, Edit rows, Export data and Run queries with a consistent interface. What’s New (2013/06/09) Full support for Firebird functionality New User Interface Added Security Manager Added PrimaryKey Selector Added Code Snippets Manager Added AutoComplete + Code Snippets [...]

Behind the connection: Dynamic web page using Delphi, ICS and DWScript

$
0
0
ICS has a web application server component which allows you to build dynamic web page very easily. Delphi code for each web page is encapsulated in a TUrlHandler class and compiled into your application, making a standalone webserver application. In the article, we will create a TUrlHandler class which will read a DWScript script from disc and execute it. The script is responsible for build a

Delphi Bistro: Having fun with FireMonkey 2 multimedia components

$
0
0

Para leer este articulo en espanol haz click aqui.

The other day I started to play with the multimedia components included on FireMonkey. I went to the web and found a couple of demos from Embarcadero. Took my time to look at the demos and followed the steps to build the demo. Cool! It worked fine! No surprises there I suppose.

However, I got to think, can I do more? What if I hack together on a form two media players – can I have two media players on form? Can I play two media players at once?

So I put together a project like so and found the answers to my questions. Yes, yes and yes. Cool!

So I turned back and asked myself can I do even more? Can I put eight media players on a form and have them play all at once? Can I use live bindings to connect certain components? Can I use minimal code? After all having an event handler per object would be really clunky, hard to maintain and make me look bad.

So I set of to do the application. I started by deciding to create all 8 player controls at design time and make it all go thru one set of event handlers. I could have done one set and instantiated as many players as I needed, but that would have taken me away from my experiment goal. But I digress.

So I started by creating a FireMonkey HD project. Then dropped a TGridLayout and set the item sizes to a height of 250 and a width of 100. Next I dropped a TPanel, a TMediaPlayer, a couple of buttons, a couple of labels and a track bar. Made 7 more copies of the panel, placing a copy per cell of my TGridLayout.  After that I went off to fix all the component names to my liking and then set the tag property to match their player position. That way I could properly address the proper player I was supposed to service at any given request.

Double Player Main Form

Double Player Main Form at design time

Then I went on to create my base form. The base form contains a single function designed to find a component by name and return it to the caller. Let’s take a quick look at the code:

// Helper function that allows forms to find it's components by name and number
// - MediaPlayer and 8 will look for MediaPlayer8
//   and if it finds will return the component otw returns nil
function TfrmBase.GetObjectByName(objName: string; Number: integer): TComponent;
var
  ComponentName: String;
begin
  // Volume Commands can only came from TTrackbar
  ComponentName := objName + IntToStr(Number);
  Result := FindComponent(ComponentName);
end;

Pretty trivial stuff. Next I make my main form descend from the base form. Then I figure which events I needed to have in order to achieve my design goals and have a functional player. The events i need are as follows:

  • procedure HandleLoadMedia(Sender: TObject);
  • procedure btnPlayClick(Sender: TObject);
  • procedure HandleVolumeChangesByTrackbar(Sender: TObject);

Now that I know what is needed to make this project tick, I will got thru each procedure in detail. But before I do, I start connecting the track bars to the volume labels under the track bar. These labels will display a numeric representation of the volume. I bind the TTrackBar.Value to the Label.Text. I also need to use the round function to get only  integers displayed on my label.

Volume trackbar Binding

Live binding for the volume track bar

I will start by going over the procedure HandleLoadMedia:

//------------------------------------------------------------------------------------------------------------
// Loads media into the media player
procedure TForm1.HandleLoadMedia(Sender: TObject);
var
  MediaPlayer: TComponent;
  PlayButton: TComponent;
begin
  // Only supported files
  OpenDialog1.Filter := TMediaCodecManager.GetFilterString;
  if (OpenDialog1.Execute) then
  begin
    // Tries to find the proper media player to load media onto
    MediaPlayer := GetObjectByName(MEDIA_PLAYER, (Sender as TComponent).Tag);
    // Makes sure it found a media player component
    if Assigned(MediaPlayer) and (MediaPlayer is TMediaPlayer) then
    begin
      // Attempts to load media
      (MediaPlayer as TMediaPlayer).Clear;
      (MediaPlayer as TMediaPlayer).FileName := OpenDialog1.FileName;
      if (MediaPlayer as TMediaPlayer).State = TMediaState.Stopped then
      begin
        // If media is recognized as valid then it enables the play button
        PlayButton := GetObjectByName(PLAY_BUTTON, (Sender as TComponent).Tag);
        if Assigned(PlayButton) and (PlayButton is TButton) then
        begin
          (PlayButton as TButton).Enabled := True;
        end;
      end;
    end;
  end;
end;

This procedure is the event for the Load button. Taking advantage of the multimedia components I ask the framework to provide me with all the supported media types. Next I ask the user to let me know which file he or she wants to load. Once I obtain the media filename I proceed to locate the MediaPlayer using my base function GetObjectByName and then load it to the media player. Notice that I receive back a TComponent and It is my responsibility to ensure that an object was returned and that  object is of the right type. I also use the media player object to verify that the file I received from the user is indeed a valid media file. For that I check that the Media State is different than Unavailable. After ensuring that everything went OK I then enable the play button.

Now, let’s examine what is needed to play the media selected by the user. Let’s take a look at btnPlayClick event:

//------------------------------------------------------------------------------------------------------------
// Handles play button
procedure TForm1.btnPlayClick(Sender: TObject);
var
  MediaPlayer: TComponent;
begin
  // Tries to find the proper media player
  MediaPlayer := GetObjectByName(MEDIA_PLAYER, (Sender as TComponent).Tag);
  // Makes sure it found a media player component
  if Assigned(MediaPlayer) and (MediaPlayer is TMediaPlayer) then
  begin
  // Does it have a valid media attached?
  if (MediaPlayer as TMediaPlayer).State <> TMediaState.Unavailable  then
    // Figures if it needs to start or stop playback
    if (MediaPlayer as TMediaPlayer).State = TMediaState.Stopped  then
      (MediaPlayer as TMediaPlayer).Play
    else
      (MediaPlayer as TMediaPlayer).Stop;
  end;
end;

Again I locate the proper media player and make all the checks as described on the HandleLoadMedia event. Then I check the media state and I reverse it. If it is playing I’ll stop it otherwse I’ll start it. Notice that this operation pauses the playback. If you wanted to rewind the media you would have to set the media player time property to zero.

Lastly, let’s take a look at the HandleVolumeChangesByTrackbar event:

//------------------------------------------------------------------------------------------------------------
// Handles volume changes
procedure TForm1.HandleVolumeChangesByTrackbar(Sender: TObject);
var
  MediaPlayer: TComponent;
begin
  // Volume Commands can only come from TTrackbar
  if Sender is TTrackBar then
  begin
    MediaPlayer := GetObjectByName(MEDIA_PLAYER, (Sender as TComponent).Tag);

    if Assigned(MediaPlayer) and (MediaPlayer is TMediaPlayer) then
    begin
      (MediaPlayer as TMediaPlayer).Volume := (Sender as TTrackBar).Value/100;

      // Some controls send notifications when setting properties,
      // like TTrackBar
      if FNotifying = 0 then
      begin
        Inc(FNotifying);
        // Send notification to cause expression re-evaluation of dependent expressions
        try
          BindingsList1.Notify(Sender, '');
        finally
          Dec(FNotifying);
        end;
      end;
    end;
  end;
end;

Yet again I locate the proper media player and make all the checks as described on the HandleLoadMedia event. I then set the volume of the mediaplayer using the value of the track bar and then I send a notification to my binding list using the Sender object – the track bar. I found that if I do not do that my  volume label underneath my track bar will not get updated.

And last but not least I want my media player to update a status label at the top of each panel every time there is a change on it’s status. So I proceed to make the binding connections. I start by connecting the media player state property to the label’s text property. But then I get an error that tells me that there is no conversion between a TMediaState and Text. More specifically the error was: “EvalError in MediaPlayerStatus1: Unable to cast or find converters between types TMediaState and string.”. Dang! Now what?

Binding Error

Live binding error message when attempting to resolve MediaState to String at design time

Custom Output Converter to the rescue!

I go searching around the internet trying to look for a solution and can not find anything. So I decide to investigate the framework and how it does it. After a few minutes digging around the FMX library I have a better understanding of what needs to be done.

I start by creating a new unit on my project and adding the following code to it:

unit MediaPlayer.StateConversion;

interface

uses System.Classes, System.SysUtils, Data.Bind.Components, System.Bindings.Helper, System.Generics.Collections,
  FMX.Types, FMX.Media;

implementation

uses System.Bindings.EvalProtocol, System.Rtti, System.Bindings.Outputs, Fmx.Bind.Consts;

const
  sMediaPlayerStateToString = 'MediaPlayerStateToString';
  sThisUnit = 'MediaPlayer.StateConversion';
  sMediaPlayerStateToStringDesc = 'Assigns a Media Player State to a String';

procedure RegisterOutputConversions;
begin
  // Assign String from State
    TValueRefConverterFactory.RegisterConversion(TypeInfo(TMediaState), TypeInfo(string),
    TConverterDescription.Create(
        procedure(const InValue: TValue; var OutValue: TValue)
        begin
          Assert(InValue.IsType(TypeInfo(TMediaState)), 'Input needs to be MediaState');

          case TMediaState(InValue.AsOrdinal) of
          TMediaState.Unavailable:
            OutValue := TValue.From<string>('Unavailable');
          TMediaState.Playing:
            OutValue := TValue.From<string>('Playing');
          TMediaState.Stopped:
            OutValue := TValue.From<string>('Stopped');
          else
            OutValue := TValue.From<string>('UNKNOW!');
          end;
        end,
    sMediaPlayerStateToString,
    sMediaPlayerStateToString,
    sThisUnit, True, sMediaPlayerStateToStringDesc, FMX.Types.TStyledControl)  // fmx only
  );
end;

procedure UnregisterOutputConversions;
begin
  TValueRefConverterFactory.UnRegisterConversion(
    TypeInfo(TMediaState), TypeInfo(string));
end;

initialization
  RegisterOutputConversions;
finalization
  UnregisterOutputConversions;
end.

What this unit does is to register a Output Converter for the live bindings framework. More specifically one that takes a TMediaState as input and it outputs the equivalent string representation of such state.

The meat of this unit lies inside the procedure RegisterOutputConversions. It calls TValueRefConverterFactory.RegisterConversion with 3 parameters: the from type(), the to type and the converter (TConvertProc). A good unit to take a look at to further understand this is System.Bindings.Outputs.

Once you know what to use, providing the converter becomes a trivial programming task. My converter was defined in the parameter of the registration procedure. However, one can define it into a TConvertProc variable and so on. I should also point out that a good understanding of the RTTI helps a lot into writing solid converters.

I choose to place an assert at the top of the procedure to make sure during development nothing else would show up and break my converter later on.

So, whit that issue resolved I compile and run the project, and what do you know? It works. It sounds really weird but it works. It work on my Windows 7 VM and on my Mac. Cool!

I also realize that the media players only update the labels once, when the form is created. In order to resolve that I use an timer so that every second I go around the media players and issue a BindingsList1.Notify. That seems to work perfectly. I also use the timer event to rewind files that are done playing so the user can replay files in case of such files being sound effects.

Adding video

Then after I satisfy my inner geek playing around with songs and audio effects I turn around and ask once again, can I do more? Yes, I  can! I want to add video to my player and see if I can play 8 videos at once. Why? Because I can?!?

So I add a second form that has a GridLayout and 8 media players arranged on the grid. Write some quick code to resize the grid as the window gets resized do I can get “optimal”  viewing pleasure. I also make sure that the window can not be closed by the user. This form is also a descendent of my base form.

I also add a onCreate event on my main form and proceed to connect the media player components to the appropriate media player controls. Once again I use my GetObjectByName to accomplish that.

//------------------------------------------------------------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
var
  MediaPlayer,
  MediaPlayerControl: TComponent;
  I: Integer;
begin
  // Creates screens form
  fScreenWall := TfScreenWall.Create(nil);
  // Assigns all playes to all media controls
  for I := 1 to 8 do
  begin
    MediaPlayer := GetObjectByName(MEDIA_PLAYER, I);
    if Assigned(MediaPlayer) and (MediaPlayer is TMediaPlayer) then
    begin
      MediaPlayerControl := fScreenWall.GetObjectByName(MEDIA_PLAYER_CONTROL, I);
      if Assigned(MediaPlayerControl) and (MediaPlayerControl is TMediaPlayerControl) then
      begin
        (MediaPlayerControl as TMediaPlayerControl).MediaPlayer := (MediaPlayer as TMediaPlayer);
      end;
    end;
  end;

  // Shows the form
  fScreenWall.Show;
end;

I then run it and to my surprise it just works! I can play 8 720p videos on my VM with no perceptible slowdown and also runs on my Mac.

dplayer running

Application running 8 videos at once on my Windows VM

Closing thoughts

I want to make sure that everybody understands that this is not meant to be a fully working program and that there is lots of improvements that can be done. Even as I write these lines I am doing my best to not try to further improve the program because it serves it’s purpose as is – to demonstrate that I can have several media players active and playing at once on my projects while using live bindings for some of the information to flow from controls to labels and so on. As a side benefit, I learned how to create an output converter for my specific needs.

Source code

The source code is available at https://github.com/TheRealFletch/dplayer. Feel free to make contribuitions to the dplayer project and push your changes back to the repository.


Delphi Bistro: Are you in Seattle on June 12th? Come meet David I then.

Pascal y Lazarus: Typhon 4.3 : nueva versión de CodeTyphon, sin mencionar a Lazarus

$
0
0

El 2 de junio pasado PilotLogic liberó la versión 4.3 de CodeTyphon. Esta vez el producto lleva el nombre de Typhon, y si vemos el Acerca de, el texto dice:


sin ninguna mención a Lazarus, aunque el IDE sigue siendo claramente el de Lazarus, eso sí, con algunas mejoras.

Instalación de CodeTyphon

La instalación en Windows es muy fácil, basta con descomprimir el paquete y ejecutar install.bat, seleccionando la opción 0 se instalará CodeTyphon Studio, una vez instalado, y en la misma ventana de terminal nos aparecerán las opciones para instalar FreePascal y Typhon. Para una instalación limpia es mejor seleccionar la opción 8. Aquí sí es necesario un poco de paciencia.

Si el Windows es de 64 bits se instalarán las versiones de 32 y 64 bits. La primer vez que lo instalé la de 64 bits no arrancaba, diciendo que faltaba una librería. Pienso que había algún conflicto con a versión 1.0.8 de Lazarus que tenía instalada en el mismo equipo. Desinstalé CodeTyphon y Lazarus, reinicié el equipo y volví a instalar CT. Esta vez, todo funcionó sin problemas.

Instalación de paquetes

El primer paquete que instalo siempre para probar compatibilidad es el IBDAC 2.70 de Devart. Una versión de CodeTyphon o Lazarus que no permita instalar esta librería no nos sirve, ya que es nuestra librería por defecto para manejar bases de datos.

Esta es la lista de librerías probadas, y su compatibilidad con las dos versiones de Typhon: 
 
LibreríaCompatible con
Typhon 32Typhon 64
IBDAC 2.70SISI
AJLazCtrlsSINO
csvBase SISI
ZVDateTimeCtrls 1.4SISI
 











El problema con AJLazCtrls es que el paquete no tiene definiciones para WIN64, necesarias para compilar en 64 bits. Habría que probar forzando la definición de 32 bits.

Usando Typhon 4.3 32 puedo compilar sin problemas nuestros proyectos Lazarus. 


Firebird News: Firebird Python driver FDB 1.3 is released

$
0
0
FDB release 1.3 is out: http://pypi.python.org/pypi/fdb Here is the changelog and the list of bugs fixed New Features * fdb.monitor submodule for access to / work with monitoring tables. * New fdb.Connection.monitor property for access to monitoring tables. Improvements * closed property and clear() method for Schema. * Unit tests reworked. Bugs Fixed * Unregistered: [...]

Firebird News: Protocol optimization (status update)

$
0
0
I got the following status update from Dmitry Yemanov, regarding the Firebird’s protocol enhancement task that is being sponsored by FDD: I’m working on it from time to time. One of the TODO items is completed, one more improvement came to mind and now it’s being tested. So it’s surely will be available in FB3, [...]

Andreano Lanusse | Technology and Software Development: Macs compatible with OS X Mavericks

$
0
0

Apple just announced OS X Mavericks and it brings some cool new features. Now come the question “Is my Mac compatible with OS X Mavericks”, below a list of Macs that will be able to run the new OS:

  • iMac (Mid-2007 or later)
  • MacBook (13-inch Aluminum, Late 2008), (13-inch, Early 2009 or later)
  • MacBook Pro (13-inch, Mid-2009 or later), (15-inch, Mid/Late 2007 or later), (17-inch, Late 2007 or later)
  • MacBook Air (Late 2008 or later)
  • Mac Mini (Early 2009 or later)
  • Mac Pro (Early 2008 or later)
  • Xserve (Early 2009)

Also, the computer needs to be running Mac OS X 10.6.7 Snow Leopard or higher, with 8GB of free disk space for installation. Essentially, that’s the exact same computer and specification requirements as Mountain Lion required—so if you installed that, you can be confident that Mavericks will run on your machine. — Apple Insider

Andreano Lanusse | Technology and Software Development
Follow me on Twitter: @andreanolanusse

Viewing all 1725 articles
Browse latest View live