As said in the previous post I started making extensions for MPDN, the media player.
One of those is the Update Checker. This is a small extension that check for new version of the player and new version of the Extensions. This update checker check for new update and let the use download them directly without the need of a browser. It does also run them after downloading them which make the update process faster and easier even for the less techy-user.
For the player, Zach is updating at every version a text file on the ftp, available from the web (http://mpdn.zachsaw.com/Latest/ChangeLog.txt). This file is queried by all the player on which the extension is installed at launch. This is an excerpt of its content.
v2.34.0 Changelog: Added streaming support for LAV supported URIs Added VideoFilters and AudioFilters properties to PlayerControl Added PlayerControl.ComInvoke() and ComInvokeAsync() methods Improved Step and Pause: They no longer cause render queue to be flushed v2.33.0 Changelog: Added missing video track members in PlayerControl class v2.32.1 Changelog: Further chroma reconstruction improvements Include OpenCL.dll v1.2 in distribution to allow systems without the correct version of ICD installed to use OpenCL Fixed: Installer now removes Windows uninstall program entry for previous version when upgrading Fixed: MPDN (64-bit edition) can lockup on some short media files if user seeks to just before the end in some situations
As you can see it does contain all the version ever released of the player. This is file will get bigger and bigger more version get release meaning the bandwidth will grow exponentially for informations unuseful to the Update Checker.
I created a small PHP script that use apcu to parse and keep in memory only the changelog for the last release. The script compare the timestamp of the changelog.txt, if it’s different it mean the script need to reparse the file to fetch the last version, else it will print what is stored in the memory. This is the url queried: mpdn.zachsaw.com/LatestVersion.txt. After this the extension have less to download (only a couple of hundred of bytes) and it reduce greatly the bandwidth.
Since the extension code is open-source and hosted on github, I convinced Zach to re-use the release feature of github to be able to provide an UpdateChecker for it too. Github provide a nice api to retrieve the last release in JSON.
zachsaw / MPDN_Extensions
Media Player .Net (MPDN) Open Source Extensions
Finding a way to get the version of the extension used by the player and compare it to the one of github
To resolve this issue, Zach decided to give a version number to the Assembly and provide the extension in dll form. Together we designed an installer using NSIS(Nullsoft Script Installer System) to install and update easily the extension. This file plus a Zipped version of the extension are attached to each release. All was a matter of using JSON.NET (because the player is using .NET 4.0 that doesn’t support JSON natively) and the assembly of the extension to check if a new version is available.
Leave a Reply