*Problem* :
Ti.Media.VideoPlayer doesn't work when app using cache on Android 5.0 Lollipop.
*Steps to reproduce* :
1. Launch app
2. Watch video (auto play)
3. Kill app
4. Launch app a second time
5. A video doesn't work
*Resolution* :
I need to clear cache of my app to watch again my video. This problem is only on Lollipop, It was working perfectly with the previous version of Android.
*Sample Alloy* :
{quote}
http://s3-eu-west-1.amazonaws.com/cf-templates-k6ohn88yswx5-eu-west-1/videos/4fbc88e7e4b0b0896e877764/4fbfd5ece4b0932236fc234d.mp4"
height="300" width="300" autoplay="true" />
{quote}
*Trace Log* :
11-26 10:32:34.290: E/NuCachedSource2(188): source returned error -1, 8 retries left
11-26 10:32:37.306: E/NuCachedSource2(188): source returned error -1, 7 retries left
11-26 10:32:40.315: E/NuCachedSource2(188): source returned error -1, 6 retries left
11-26 10:32:40.491: E/REQUEST(6264): ERROR
11-26 10:32:40.491: E/REQUEST(6264): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.StatusLine.
(StatusLine.java:24)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.Response$Builder.statusLine(Response.java:419)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.JavaApiConverter.createOkResponse(JavaApiConverter.java:116)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.ResponseCacheAdapter.get(ResponseCacheAdapter.java:53)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:190)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:208)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
11-26 10:32:40.491: E/REQUEST(6264): at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25)
11-26 10:32:40.491: E/REQUEST(6264): at com.google.maps.api.android.lib6.b.l.run(Unknown Source)
11-26 10:32:40.491: E/REQUEST(6264): at java.lang.Thread.run(Thread.java:818)
11-26 10:32:43.330: E/NuCachedSource2(188): source returned error -1, 5 retries left
11-26 10:32:45.049: E/WifiStateMachine(596): WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=116,23 rxSuccessRate=206,11 targetRoamBSSID=any RSSI=-53
11-26 10:32:46.344: E/NuCachedSource2(188): source returned error -1, 4 retries left
11-26 10:32:49.357: E/NuCachedSource2(188): source returned error -1, 3 retries left
11-26 10:32:52.389: E/NuCachedSource2(188): source returned error -1, 2 retries left
11-26 10:32:55.412: E/NuCachedSource2(188): source returned error -1, 1 retries left
11-26 10:32:56.634: E/audio_a2dp_hw(188): adev_set_parameters: ERROR: set param called even when stream out is null
11-26 10:32:56.639: E/native(596): do suspend true
11-26 10:32:57.414: E/ANDR-PERF-LOCK(195): Failed to apply optimization for resource: 4 level: 0
11-26 10:32:58.427: E/NuCachedSource2(188): source returned error -1, 0 retries left
11-26 10:32:58.523: E/GenericSource(188): Failed to init from data source!
11-26 10:32:58.541: E/MediaPlayer(24537): error (1, -2147483648)
11-26 10:32:58.549: E/MediaPlayer(24537): Error (1,-2147483648)
Hi Miranda&Jonathan. I believe I have the same issue, but worse. while trying to play HLS on Lollipop - never plays. on KitKat - the same code plays great. I'm a developer of a big client in the Security Area, with a very complex application. It's very urgent for us. log: 12-28 11:07:50.842: I/TiAPI(9216): cameraVodURL: http://5.102.236.132:50032/hls/vod.m3u8?sid=t1L3AUby2ykMK51JQJeZjniXjGDIB6qT 12-28 11:07:50.853: D/MediaPlayer(9216): Couldn't open file on client side, trying server side 12-28 11:07:50.860: I/LiveSession(183): onConnect http://
I am curious if this is an Android bug. See https://code.google.com/p/android-developer-preview/issues/detail?id=1820 and (possibly) https://code.google.com/p/android/issues/detail?id=72875.
Hi, I have also the same issue with Ti.Media.AudioPlayer that is include in the Android MediaPlayer. It is also urgent for me to fix the bug. Thank you
It looks like an android bug. Disabling the cache on the connection works around this. You can call setUseCaches(false) on the URL connection. But this is just a workaround, not a solution.
This is caused by a bug in TiCacheResponse. I reported this in a separate issue - TC-5388 Also see: http://stackoverflow.com/a/29147399/2603965
I have the same issue. It affects both AudioPlayer and VideoPlayer. This is critical. Please fix asap. Thanks.
Where can I set setUseCaches for AudioPlayer and VideoPlayer?
There's another workaround. You can fool the cache by adding at the end of the url: "&random="+Math.random()
But that'll create duplicate cache, right? I'm considering deleting the cache folder every time the app starts. How do I empty the cache folder /Android/data/appid/cache/_tmp/remote-cache/ programmatically from Titanium? Thanks a lot!
Shawn, sorry to say, but you got to the point where you need to learn how to build titanium and start fixing things yourself...
When I play the video, I also get the following error: [ERROR] : TiResponseCache: (Binder_4) [67159,67159] Failed to add item to the cache! And when I close the window that has the video player, I get the following error: [ERROR] : MediaHTTPConnection: unknown exception java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[], int, int)' on a null object reference Are the errors above related to this ticket as well? Does anyone get the same errors?
I managed to work around this issue on Android 5.0 by using a random parameter appended to the video url. However, the problem is back on Android 5.1 and I have never managed to play a video on it. *Titanium SDK:* 3.5.2 *Error:* NuCachedSource2: source returned error -1 *Sample video url:* http://83993dd4bb14485827c6-0dc03e64f4df23ed221a7e1a04718347.r67.cf3.rackcdn.com/62b0974e1c870b9537e759ce223934086d8a482a.mp4
This does seem to have the same error signature as in TIMOB-18887. Linking the two issues as duplicates. The other is closed, we will try that fix with this sample code.