Has anyone faced issues with TextureView and MediaPlayer on Android 4.2.2?
SOLVED: See answer below and how to serve files from an embedded HTTP server.
UPDATE: The videos which fail to display if embedded in the res/raw folder play just fine if they are hosted online. See below for example:
// This works
mMediaPlayer.setDataSource("http://someserver.com/test.mp4");
//This does not work. The file is the same as the one above but placed in res/raw.
String vidpath = "android.resource://" + getActivity().getPackageName() + "/" + R.raw.test;
mMediaPlayer.setDataSource(getActivity(), Uri.parse(vidpath));
We need a texture view so we can apply some effects to it. The TextureView is used to display a video from the MediaPlayer. The application works on Android 4.1, 4.3 and 4.4 (on many devices including the old Nexus S up to the Nexus 10 and Note 3) but on 4.2.2 the TextureView becomes black. There are no errors or exceptions reported by the MediaPlayer and the reported video sizes are correct. Testing a SurfaceView on this particular device displays the video, but then we can't manipulate the view the way we need to.
One interesting bit is that a TextureView works on that device if playing the Nasa Live Streaming Video feed and some other streaming m3u8 files (http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8) but we need to play embedded videos from the raw folder. We noticed however that at the very top of the TextureView, there's a 4x1 pixel line which keeps blinking some colors very rapidly. I wonder if the media player is rendering the video on that hairline or maybe it is an encoding problem or a hardware issue (this particular 4.2.2 device is a mimic of the iPad mini called... the haiPad >.< (which of course is the client's target device - hate you Murphy)).
Here's the info I could gather about the video which is failing to play:
MPEG-4 (Base Media / Version 2): 375 KiB, 5s 568ms
1 Video stream: AVC
1 Audio stream: AAC
Overall bit rate mode: Variable
Overall bit rate: 551 Kbps
Encoded date: UTC 2010-03-20 21:29:11
Tagged date: UTC 2010-03-20 21:29:12
Writing application: HandBrake 0.9.4 2009112300
Video: 466 Kbps, 560*320 (16:9), at 30.000 fps, AVC (Baseline@L3.0) (2 ref Frames)
Anyone has any pointers?