Back-ported some rotation changes from upstream so that rotation of videos works on iOS 6