Skip to Content

jwPlayer & SMIL = No Repeats

Written on June 1, 2011 at 2:12 pm, by

http://developer.longtailvideo.com/trac/ticket/1216 – Looks like this is an identified problem with jwPlayer 5.6 for now and some time to come.  If you have a need to stream a multi-bit rate file via a SMIL through Akamai’s RTMP service, you may be frustrated to find out that users will not be able to repeat the video at the end of playback as expected.

Fortunately, I’ve found that adding the playerReady function indeed will work, especially if you just force the player to load the SMIL all over again when the state equals COMPLETED.

Here’s a sample:
var player = null;

function playerReady(obj) {
player = document.getElementsByName(obj.id)[0];
player.addModelListener("STATE", "stateMonitor");
}
function stateMonitor(obj){
if(obj.newstate == "COMPLETED" ) {
player.sendEvent('LOAD',{'file':'/videos/smil/smilfile.smil','provider':'rtmp'});
} }

Works like a charm.

jQuery .clone

Written on May 26, 2011 at 1:46 pm, by

If jQuery were a woman, I would make sweet love to it.

How many other folks out there find themselves scratching their head about the complexities they are spared by using jQuery?

I ran into a situation where I needed to shift a quantity drop down from an input box to a select box with dynamic options, and back, using JavaScript.  I don’t care for it, but it’s the situation in which I find myself.

What I want to do – render an input box (in this case, we’re using cfinput at runtime), and then replace it with a select box based off an item selected in another select box, to constrain quantity.  ColdFusion is creating the array at run time which contains the select variables.

Convoluted?  Yes, but this is the world in which we live with enterprise-level e-commerce systems.

First, the variable, defined in a global scope.

IPv4 Tools for ColdFusion

Written on April 5, 2011 at 2:05 pm, by

Our PHP friends have all the fun with their functions, like IP to long and what not.  We’ve duplicated some of that.

For a recent project where orders coming from IPv4 addresses outside the country are flagged in our system as fraud, I ran into the problem that the free databases that correlate ISO country code to IP ranges no longer include the CIDR data.

Web service calls were unapproachable for the volume of the update, as there are any number of free services out there that will find the CIDR for a range of IPs for you.

Here are a couple of functions I banged out to quickly calculate the net mask value from a range.  It’s not a catchall, mind you, there are always places where more subnets are applicable, but it seemed to work well for my purposes.  And at any rate, given the paucity of information out there on the web for performing this kind of function with ColdFusion, I believe it’s ultimately helpful.


// Function: getOctet: Takes in a piece of an IPv4 address and returns the appropriate length binary string (i.e. 10101010)
function getOctet(ippart) {
var octetpart = FormatBaseN(ippart,2);
var addstring = "";
if (len(octetpart) lt 8) {
for ( i = 1; i lte (8 - len(octetpart)); i++ ) {
addstring &= 0;
}
}
return addstring & octetpart;
}

// Function: calcNetMask: depends on getOctet, takes in two IP addresses in a range and calculates the subnet mask and CIDR for the range, only works for very specific ranges
// i.e. countries
function calcNetMask(ip1,ip2) {
var Local = StructNew();
Local.binary1 = getOctet( ListGetAt(ip1,1,”.”)) & getOctet( ListGetAt(ip1,2,”.”)) & getOctet( ListGetAt(ip1,3,”.”)) & getOctet( ListGetAt(ip1,4,”.”));
Local.binary2 = getOctet( ListGetAt(ip2,1,”.”)) & getOctet( ListGetAt(ip2,2,”.”)) & getOctet( ListGetAt(ip2,3,”.”)) & getOctet( ListGetAt(ip2,4,”.”));
Local.subnet = ”;
for ( i = 1; i lte 32; i ++) {
if ( CompareNoCase( Mid(Local.binary1,i,1), Mid(Local.binary2,i,1) ) eq 0 ) {
Local.subnet &=1;
Local.netmask = i;
} else {
Local.subnet &=0;
Local.netmask = i – 1;
break;
}
}
if (len(Local.subnet) LT 32) {
addstring = “”;
for ( x = 1; x lte ( 32 – len(Local.subnet)); x++) {
addstring &= 0;
}
Local.subnet = Local.subnet & addstring;
}
Local.SubNetMask = InputBaseN( Mid(Local.subnet,1,8),2) & “.” & InputBaseN( Mid(Local.subnet,9,8),2) & “.” & InputBaseN( Mid(Local.subnet,17,8),2) & “.” & InputBaseN( Mid(Local.subnet,25,8),2);
// I like to clean up variables I’m not going to return
delkeys = ‘binary1,binary2,subnet’;
for ( n = 1; n lte listLen(DelKeys,”,”); n++) {
StructDelete(Local,ListGetAt(delkeys,n,”,”));
}
Local.CIDR = ip1 & “/” & Local.netmask;
return Local;
}

You’ll note that final function returns a structure of data. I don’t know, you might want to know some of those other values for your own edification.

It makes you wonder, though…how many of these functions are going to be orphaned as we more widely embrace IPv6.  Right now, all I know about IPv6 are the issues I’ve had with DIG and DNS on Mac OS X.  We’ll have to see.

EXIF Data, Coldfusion, and iPhones

Written on March 2, 2011 at 4:02 pm, by

Like so many others have discovered, iPhones shave processing and battery expenditures by writing image orientation data to EXIF data, rather than physically reorienting the image.

I’ve seen cumbersome uses of libraries and such for people seeing a solution with CFIMAGE.

To quote a coworker – quick and dirty – without having to incorporate new classes or jump through tremendous hoops.

First, either by cfimage or imageRead, get the file.
Then, create a structure using ImageGetExifMetaData, so you can get at the Model and possibly Orientation properties.

To correct the rotation, right or right side specifications under Model “iPhone 4″ go clockwise 90 degrees, left or left side seem to work with -90 degrees counterclockwise. ImageRotate will handle this.

Finally, the magic. Manipulating that data either with CFScript or cfimage, and saving down the file WILL preserve the EXIF data. There are a variety of reasons why you might want to strip that out; user privacy, file size, etc.

What WILL get rid of it–again, quick and dirty–is the following:

blankImg = ImageNew("",ImageGetWidth(oldimg),ImageGetHeight(oldimg));
ImagePaste(blankImg,oldimg,0,0);

Then write out that new image. Try ImageGetExifMetaData on the new one, you’ll be pleasantly surprised that with the paste operation, CF does not preserve the EXIF data with the paste operation.

Certainly, this works with CF8. I will test with CF9, and hope that this is not considered a bug. I would hope this absence of functionality, if you will, is a feature, given the absence of an ability to remove or modify the EXIF data by other means.

Fun with CFIMAGE and CF9

Written on October 21, 2010 at 2:25 pm, by

Layout woes.
Lets say you want to construct a layout with layered PNGs, but you need it to be backwards compatible with older browsers because that’s the nature of your synagogue membership and their computers.
First, let me warn that this is expensive if you run this each and every time an IE user comes to your site. I would always opt for the client-side PNGFix scenarios, but there are times when your design is just so cool but not possible to quickly make compatible with the variety of browsers out there.

Here’s a simple version that seems to work for my site with IE 6.


If ( ListGetAt(CGI.HTTP_USER_AGENT,2,";") eq "MSIE 6.0"){
// above checks for IE 6 in the CGI variable, below checks our "cache" to ensure we don't already
// have said file
if(not FileExists(ExpandPath("images/headercache/test.png"))) {
// this now creates our working image, with the appropriate dimensions
BlockImage = ImageNew("",800,194);
// in CF9, not sure in CF8, ImageNew can create an object out of existing files, which is what we do here
LeftImage = ImageNew("images/graphic_bar_left.png");
NavImage = ImageNew("images/graphic_bar_nav_bg.jpg");
LogoImage = ImageNew("images/graphic_bar_logo.png");
BackgroundImage = ImageNew("images/frontpage/mainsanctuary.jpg");
//ImagePaste lets us take the image, the first argument, and paste the image in the second argument
// at the x and y (third and fourth arguments) respectively.
ImagePaste(BlockImage,BackgroundImage,0,0);
ImagePaste(BlockImage,LeftImage,0,0);
ImagePaste(BlockImage,NavImage,72,0);
ImagePaste(BlockImage,LogoImage,198,0);
// we now write that image to file. I could have opted to write it to browser, but figuring this
// this process could be quite expensive, I'd rather check against the file system first. In my real
// world implementation, the background image is randomly pulled from a list of objects, so I'd have
// variable filenames for all of this.
ImageWrite(BlockImage,"images/headercache/test.png");
}
}

ColdFusion is very, very nice at times.

Ebay's File Transfer API Redux

Written on October 21, 2010 at 2:08 pm, by

For anyone that needs to know this for ColdFusion…
I previously had to rename zip files to .gz and pass them through Ebay’s API (http://developer.ebay.com/devzone/file-transfer/CallRef/uploadFile.html).
This is one of the more poorly documented and arcane pieces of this process. This morning, our bulk insertions were failing with the “evil payload” error (I paraphrase). Now, it would seem, contrary to an Indian developer on Ebay’s developer forums, that the File Transfer Service does accept plain old zip files without tricking the system with a .gz extension. We’ll see how long this one lasts. I had hoped to automate a number of these functions but have held off precisely because of this sort of thing.

Any takers? How does one save a MIME SOAP attachment in ColdFusion?

Written on August 18, 2010 at 12:31 pm, by

I’m hoping this can be done without exposing Java or writing a CFX tag.

Here’s the SOAP response:
--MIMEBoundaryurn_uuid_1D0A148B118BC1B6331282134264575299 Content-Type: application/xop+xml; charset=utf-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: Success1.1.02010-08-18T12:24:24.575Z1202 --MIMEBoundaryurn_uuid_1D0A148B118BC1B6331282134264575299 Content-Type: application/zip Content-Transfer-Encoding: binary Content-ID: PK����7��9�g��6��������AddFPItem.xml�X�n�6}n����O-`[�����I o��ޠO Z�DdJ%���ח�dIVl��@��KB͙+9C����Y�\А}hXm�ȼЧl��E�����{�/C"�h� [�����=J�����DT�`��O�u2dR4�����<]���YX�{ufۏs���c�F�J퍊 ���t���S�%��"�1 A�:�ձ.;�ymZ�QJ3��!T��J� �2smcW�g�L8S��8wt����?(^���׀H\�I'""�[��klG���0�^� �|`!��MУ �6|�7�D_�U��Q�Z�}x^����l�⽴+��.�o`�L���ӄ�XVF1#�� �q�>��M6a�S!�.�&G��M�6�ŗ;�W1UE���QgW���� cNR'C��/g���@�b�D��va�b�A�e.\��P����V\(NH�VM?F� }�� l�&��+|�&4PS��,8RM��K-i{�:5����\� O��Y��fV�uqv�5��gV�H�Wݧ+��q��hP��E�+�����F�_ \�N��: +�x�y�� rB��O��8A���Cxy2{��p<���3���2�N3�{� 5���n�h�S�K�q�ov��t�V���E��Ƒ�:\�t��bMGuq�u�Ze�u蘽��'�V

MTOM and ColdFusion

Written on August 13, 2010 at 12:18 pm, by

Has anyone ever figured out how to add a mime attachment using MTOM / XOP:Include and CFHTTP? My problem seems to be a matter of binary encoding. I could expose the underlying Java or write a CFX, but for one meager function in a forest of other successful SOAP calls, I had really hoped to use one ubiquitous function for actually touching the variety of web services.

For now, until I can come up with something better, we have the capability of adding PHP to the mix, so I may use that until I have real time to commit to making something work for ColdFusion, but if anyone has any ideas, let me know.

Code for a Dealer Locator in Coldfusion

Written on November 5, 2009 at 8:51 pm, by

SELECT zipcode as zip, latitude as lat, longitude as long
FROM zipcodedatabase
WHERE zipcode='#form.zip#'

SELECT zipcode, latitude, longitude,
3963 * (ACOS((SIN(#userzip.lat#/57.2958) * SIN(latitude/57.2958)) +
(COS(#userzip.lat#/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - #userzip.long#/57.2958)))) AS distance
FROM zipcodedatabase
WHERE (3963 * (ACOS((SIN(#userzip.lat#/57.2958) * SIN(latitude/57.2958)) +
(COS(#userzip.lat#/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - #userzip.long#/57.2958)))) <= #form.miles#)
GROUP by zipcode, latitude, longitude
ORDER BY distance

SELECT *
FROM
tblEatMe
WHERE CONVERT(nvarchar(5), Zip) IN (#selectzips#)

I feel all right about this, years after I initially wrote it. First it retrieves the longitude and latitude data for a particular zip code from my database table.
Next, while accounting for the curvature of the earth, it finds other zip codes within the specified mileage radius. Finally, it pulls all the relevant records from my dealer table by zip code with that cool T-SQL convert function going on.

I’d like to further refine it to list these things by distance, but building the query is making my head explode. If I figure it out, I’ll post again on this topic.

Dumping Macromedia ColdFusion for ASP.NET

Written on April 4, 2005 at 3:04 pm, by

We finally pulled it off, and I should say, I finally pulled it off.

I always said that Coldfusion is a nice toy for designers who want to be developers. It follows a form that is easily understood by those who already grasp HTML. I have nothing against this; ineed, it’s a powerful and useful environment.

My problem, however, is that if they’re going to base it in J2EE, just give me Java and be done with it.

With our volume of users and the volume of data we’re distributing through www.boschsecurity.us, we needed something a little more robust than Coldfusion can afford. I’ve never seen a large volume Coldfusion-based site have the kind of up-time that is desireable. Its data-center functionality and load-balancing capabilities are dependent on other platforms, again. It’s sort of like the candy-coated shell for other platforms that do all the hard work!

Take www.myspace.com, the hipster hangout on the web. It’s built in ColdFusion, and it breaks more often than not.

.NET had features that made life much better. Using ADO.NET, for one, offers vast improvements, measured by benchmarks, in touching our database. Using Datasets and Datagrid objects reaped dividends for extending functionality, such as “searching within searches.” There’s also a lot to be said for using Microsoft solutions with Microsoft solutions (.NET plays extremely well with SQL Server 2000).

We have more data definitions than some women have shoes.

I’ll talk more about where and how .NET is specifically helping Bosch Security Systems as time permits.