What is the difference of 540x960 and 640x960?

I have a 540x960 sony xperia m2 and my iPhone has 640x960. The confusing part is that the iPhone can play in hd while the m2 can't. I can still play hd on my m2 on 3rd party apps like viral pro ( youtube won't let me play hd but viral can). So tell me, what is the difference of these resolutions?

The iPhone lies, sort of. True 16:9 720p, otherwise known as HD, is a resolution of 1280x720.

The iPhone can output a resolution of 720p if you connect it to a HDTV, but if you play a 720p HD file (or Youtube video) on your iPhone it's going to get downscaled to 640x960. Just like your Sony m2 will downscale to 540x960.

100 pixels.

The resolution of the display is not what affects its ability to play HD videos or not. That's down to the internal components of the phone.