{ "id": "172119", "key": "TIMOB-26334", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-10-02T15:31:59.000+0000", "created": "2018-08-23T12:44:21.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "audioplayer", "ios" ], "versions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-10-10T12:32:32.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Having tested SDK mobilesdk-7.5.0.v20180821233900-osx to try the new (long-awaited) AVPlayer-based Ti.Media.audioPlayer I have discovered a crucial bug. \r\n\r\nAfter setting up a player and then using `player.setUrl(URL)` it works fine. \r\n\r\nIf you then try to setUrl again, the app will crash. \r\n\r\nThis is due to the notification observer for \"timedmetadata\" not being removed. \r\n\r\nTo test: \r\n\r\n{code:js}\r\n var test_player = Ti.Media.createAudioPlayer({ \r\n allowBackground: true\r\n });\r\n\r\n var btn = Ti.UI.createButton({\r\n title:'set url'\r\n });\r\n btn.addEventListener('click', function(e){\r\n test_player.setUrl('URL TO MP3');\r\n // Will crash on second call.\r\n });\r\n{code}\r\n\r\nTo fix the issue, please add one line to TiMediaAudioPlayerProxy.m at line 422: \r\n\r\n{{[[[self player] currentItem] removeObserver:self forKeyPath:@\"timedMetadata\"];}}\r\n\r\n\r\n\r\n", "attachment": [ { "id": "65473", "filename": "sample.mp3", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-24T07:04:53.000+0000", "size": 37596, "mimeType": "audio/mp3" } ], "flagged": false, "summary": "iOS: New AVPlayer-based Ti.Media.audioPlayer crashes on second setUrl() call", "creator": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "environment": null, "comment": { "comments": [ { "id": "441026", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "I also notice that the docs mention that AVPlayer is being used in 7.4.0. I could only find it in the continuous 7.5.0 builds. \r\n\r\nhttps://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.AudioPlayer\r\n\r\nThe example provided in the docs works fine, since the url is never changed. \r\n\r\nChanging the url will crash the app since the timedmetadata observer is never removed. \r\n\r\n\r\nAnother issue is that the NSNumber duration method doesn't return anything. ", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2018-08-23T19:23:13.000+0000", "updated": "2018-08-23T19:23:13.000+0000" }, { "id": "441035", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks [~kosso]! The observers are a big mess, especially when we need to use so many of them, being a framework. We will address this in 7.5.0, where this will be introduced. Side note: 7.4.0 will be dedicated for iOS 12 and Xcode 9 support, aligning with Apples timelines.\r\n\r\n*EDIT*: I cannot reproduce the issue with the following test-code (sample.mp3 attached):\r\n{code:js}\r\nvar test_player = Ti.Media.createAudioPlayer({ \r\n allowBackground: true\r\n});\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n });\r\n \r\n var btn = Ti.UI.createButton({\r\n title: 'Trigger'\r\n });\r\n \r\n btn.addEventListener('click', function() {\r\n // Will crash on second call.\r\n test_player.url = 'sample.mp3';\r\n });\r\n \r\n win.add(btn);\r\n win.open();\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-24T06:51:40.000+0000", "updated": "2018-08-24T07:04:42.000+0000" }, { "id": "441036", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I am still not able to reproduce the crash related to \"timedMetadata\", but here is a fix for the duration and the listener to (very likely) fix the other one as well. It was simply missing from the observer-cleanup method and makes sense to be required.\r\n\r\nPR: https://github.com/appcelerator/titanium_mobile/pull/10285", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-24T07:26:59.000+0000", "updated": "2018-08-24T07:26:59.000+0000" }, { "id": "441039", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "Hi,\r\n\r\nHere's a version of the TiMediaAudioPlayerProxy.m which I have got to work.\r\nhttps://gist.github.com/kosso/5fcd7ded25b0cc8ec932db633f995053\r\n\r\nbtw: I work for a radio/music company and have had to use my own (imperfect) Audio modules for some time now, since the Titanium audio player modules have been SO far apart in parity for many many years. This has been incredibly frustrating to see simple errors in status codes and missing methods. \r\n\r\nRegarding the timedmetadata error, maybe my test isn't the most complete code. But you only need to read the code to see the missing observer removal. (My current app is a 'playlist' music app.)\r\n\r\n\r\nI also see that Android is missing the seekToTime method and 'seek' complete event, despite that fact that it has the 'setTime()' method. Another hole in the parity. \r\n\r\nI also see that in iOS you automatically 'restart' the audio after the setUrl() method. Please do not ever do this. The start() method should only be used to start the audio. Also Android does not do it. \r\n\r\n\r\nIt's not your fault Hans, but for years I find it incredible that software for a \"mobile phone\" - which is device initially naturally designed for audio - has such a gaping disparity when it comes to AUDIO APIs. :) \r\n\r\n\r\nIt's been many years since I had to locally build the SDK (with scons) to patch up the holes left in the SDK, but I really really need working Audio APIs, so it looks like I'll be building again to solve my issues. :( \r\n\r\n\r\nIf you have something you need me to test out, please let me know. Since I now have many years of experience with Titanium audio apps for news, radio, music and social applications. \r\n. \r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2018-08-24T10:37:13.000+0000", "updated": "2018-08-24T10:40:49.000+0000" }, { "id": "441040", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "iOS also throws a url-related error if you try to add the progress event listener before setting the url. (Which becomes painful when building a long music playlist player app, meaning listeners need to be constantly removed and added each time.) \r\n\r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2018-08-24T10:55:55.000+0000", "updated": "2018-08-24T10:57:23.000+0000" }, { "id": "441042", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "I also note that iOS is missing the 'time' property which Android has. \r\n\r\nI got this using : \r\n\r\n{code}\r\n- (NSNumber *)time\r\n{\r\n _time = (int)(CMTimeGetSeconds([[[self player] currentItem] currentTime]) * 1000 );\r\n return NUMINT(_time);\r\n}\r\n{code}\r\n\r\nas well as defining in the header.", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2018-08-24T12:36:05.000+0000", "updated": "2018-08-24T12:36:05.000+0000" }, { "id": "441043", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "I also noticed your fix for the duration. I see you returned a NUMDOUBLE. \r\n\r\nWouldn't NUMINT be preferable when the value is always going to be integer milliseconds? ", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2018-08-24T12:37:11.000+0000", "updated": "2018-08-24T12:37:11.000+0000" }, { "id": "441049", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks for the feedback [~kosso], really really valuable! I will rework on the audio-player to get it shaped. If you have a working solution (based on the core-sdk), please also feel free to submit a PR and we can go from there. That might be the easiest way to polish up the API via GitHub communication. Could you do that? Then I'd close my other PR above.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-24T17:11:06.000+0000", "updated": "2018-08-24T17:11:06.000+0000" }, { "id": "442483", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "*Closing ticket.* Verified fix on SDK Version {{7.5.0.v20181008124804}}. Not able to see the application crash using Ti.Media.audioPlayer on second setUrl() call.\r\n\r\n*Test Environment*\r\n{code:java}\r\nAPPC Studio: 5.1.0.201808080937\r\niPhone 6 (12.0)\r\nAPPC CLI: 7.0.7-master.4\r\nOperating System Name: Mac OS Mojave\r\nOperating System Version: 10.14\r\nNode.js Version: 8.9.1\r\nXcode 10.0\r\n{code}\r\n", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-10T12:32:21.000+0000", "updated": "2018-10-10T12:32:21.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }