DelphiTools.info: DWScript news roundup for June 2013
Firebird News: Hopper v1.3.0 – stored procedure/trigger debugger – released
Andy's Blog and Tools: JCL and JVCL have completed the move to GitHub
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
Things That Turbo Pascal is Smaller Than.
Well basically anything.
About 30k was the size our complete IDE in the 80s century.
–jeroen
Filed under: Delphi, Development, Pascal, Software Development, Turbo Pascal
It's a blong, blong, blong road...: ‘Dynamic’ Delphi/C++ samples on SourceForge via Subversion
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:
- https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/trunk for the main demo trunk, although this misses out a bunch of XE4 demos, so maybe a specific branch (see rest of this list) might be more appropriate
- https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE– RAD Studio XE demos
- https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE2– RAD Studio XE2 demos
- https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE3– RAD Studio XE3 demos
- https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE3_Update– RAD Studio XE3 demos, including 64-bit C++
- https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE40– RAD Studio XE4 demos, including iOS demos
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:
- RAD Studio 2010 main page
- RAD Studio XE main page
- RAD Studio XE2 main page
- RAD Studio XE3 main page
- RAD Studio XE4 main page
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
- 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
http://forms.embarcadero.com/AMUSCA1306RADXE4Tour-SaltLakeCity
twm’s blog: Using dBase
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:
- Beginners’ Corner — Part 2: The dBASE Tables
(or how to create a table, entering, viewing and indexing data) - dBase on Wikipedia
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
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
Andy's Blog and Tools: DDevExtensions 2.7 for 2009-XE4 released
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
Name | IDE Version | File | Size | Downloads | Added |
---|---|---|---|---|---|
DDevExtensions 1.61 | 5-2007 | DDevExtensions161Setup.zip | 734.07 KB | 14290 times | 2009-01-10 |
DDevExtensions 2.7 Features | DDevExtensionsFeatures.pdf | 595.28 KB | 350 times | 2013-06-06 | |
DDevExtensions 2.4 | 7, 2007 | DDevExtensions24Setup7_2007.zip | 535.41 KB | 4831 times | 2011-07-25 |
DDevExtensions 2.7 | 2009-XE4 | DDevExtensions27.7z | 740.81 KB | 390 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
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
Name | IDE Version | File | Size | Downloads | Added |
---|---|---|---|---|---|
IDE Fix Pack 5.3 for 2009 | 2009 | IDEFixPack2009Reg53.zip | 169.52 KB | 1 times | 2013-06-07 |
IDE Fix Pack 5.3 for 2010 | 2010 | IDEFixPack2010Reg53.zip | 155.56 KB | 2 times | 2013-06-07 |
IDE Fix Pack 5.3 for XE | XE | IDEFixPackXEReg53.zip | 144.64 KB | 5 times | 2013-06-07 |
IDE Fix Pack 5.3 for XE2+UP4+Hotfix1 | XE2+UP4+HF1 | IDEFixPackXE2Reg53.zip | 210.66 KB | 3 times | 2013-06-07 |
IDE Fix Pack 5.3 for XE3 | XE3 | IDEFixPackXE3Reg53.zip | 206.45 KB | 5 times | 2013-06-07 |
IDE Fix Pack 5.3 for XE4 | XE4 | IDEFixPackXE4Reg53.zip | 206.12 KB | 5 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
Interesting graph here: Evented Github Adventure – Sentiment Analysis of Github Commits.
It seems that Delphi programmers have a much better happy/sad word rate than other programmers.
–jeroen
Filed under: Delphi, Development, Distributed Version Control, git, Software Development, Source Code Management
Firebird News: Database .NET 8.6 released
Behind the connection: Dynamic web page using Delphi, ICS and DWScript
Delphi Bistro: Having fun with FireMonkey 2 multimedia components
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.
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.
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?
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.
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.
This June 12th 2013 David I will be visiting Seattle to present the “RAD Studio XE4 Tour”. This event is organized by the Pacific Northwest Delphi User Group and Embarcadero. To register for this event go to http://forms.embarcadero.com/AMUSCA1306RADXE4Tour-Seattle.
I also would like to invite you to join our user group by going to our site and registering.
Pascal y Lazarus: Typhon 4.3 : nueva versión de CodeTyphon, sin mencionar a Lazarus
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:
| |||||||||||||||||||
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
Firebird News: Protocol optimization (status update)
Andreano Lanusse | Technology and Software Development: Macs compatible with OS X Mavericks
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
Related Posts
Andreano Lanusse | Technology and Software Development
Follow me on Twitter: @andreanolanusse