Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18888] Android Lollipop problem cache with MediaPlayer

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsTCSupportTriage, android, cache, lollipop, video
ReporterJonathan
AssigneeUnknown
Created2014-11-26T10:03:13.000+0000
Updated2018-02-28T19:55:18.000+0000

Description

*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)

Attachments

FileDateSize
lollipopMediaVideo.zip2014-11-26T10:03:13.000+00003024422

Comments

  1. Eyal Solodki 2014-12-29

    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:// 12-28 11:07:50.869: E/LiveSession(183): unable to fetch master playlist http://. 12-28 11:07:50.871: E/MediaPlayer(9216): error (1, -1004) 12-28 11:07:50.911: E/MediaPlayer(9216): Error (1,-1004) 12-28 11:07:50.912: D/TiVideoView8(9216): (main) [40530,40530] Error: 1,-1004 12-28 11:07:51.043: D/HTTPClient(9216): The persistent handle is disposed. 12-28 11:07:51.087: D/NuPlayerDriver(183): reset(0xb4920520) 12-28 11:07:51.094: D/NuPlayerDriver(183): notifyResetComplete(0xb4920520) 12-28 11:07:51.096: D/NuPlayerDriver(183): reset(0xb4920520) 12-28 11:07:51.100: D/MediaPlayer(9216): Couldn't open file on client side, trying server side 12-28 11:07:51.104: I/LiveSession(183): onConnect http:// 12-28 11:07:51.113: E/LiveSession(183): unable to fetch master playlist http://. 12-28 11:07:51.114: E/MediaPlayer(9216): error (1, -1004) 12-28 11:07:51.147: E/MediaPlayer(9216): Error (1,-1004) 12-28 11:07:51.147: D/TiVideoView8(9216): (main) [235,40765] Error: 1,-1004 12-28 11:07:52.143: D/audio_hw_primary(183): disable_audio_route: reset and update mixer path: low-latency-playback 12-28 11:07:52.143: D/audio_hw_primary(183): disable_snd_device: snd_device(2: speaker)
  2. Ingo Muschenetz 2015-01-05

    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.
  3. Vincent Grivel 2015-01-08

    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
  4. grebulon 2015-03-16

    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.
  5. grebulon 2015-03-31

    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
  6. Shawn Lan 2015-05-05

    I have the same issue. It affects both AudioPlayer and VideoPlayer. This is critical. Please fix asap. Thanks.
  7. Shawn Lan 2015-05-05

    Where can I set setUseCaches for AudioPlayer and VideoPlayer?
  8. grebulon 2015-05-06

    There's another workaround. You can fool the cache by adding at the end of the url: "&random="+Math.random()
  9. Shawn Lan 2015-05-06

    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!
  10. grebulon 2015-05-07

    Shawn, sorry to say, but you got to the point where you need to learn how to build titanium and start fixing things yourself...
  11. Shawn Lan 2015-05-07

    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?
  12. Daniel Tanti 2015-05-14

    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
  13. Patrick Mounteney 2015-06-06

  14. Eric Merriman 2015-06-23

    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.

JSON Source