Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3375] TiAPI: Implement several missing Ti.Media.AudioPlayer features

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2018-01-13T20:47:34.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterRonnie Swietek
AssigneeHans Knöchel
Created2011-04-15T03:43:29.000+0000
Updated2018-08-06T17:41:06.000+0000

Description

*Problem description* Ti.Media.AudioPlayer is lacking several features. Because of this, developing an audio player with the current API is not possible. For example, Ti.Media.Sound has a duration property, which isn't available in Ti.Media.AudioPlayer. *Proposed fixes (available in linked repositry)* - ADD duration read-only property - ADD time property (for seeking) - ADD volume property - ADD next/prev and seeking remote control events - FIX play/pause remote controls don't work when using background audio - FIX changing the URL doesn't work (unless you stop first) - FIX progress events only fire for the first URL Also suggested on http://stackoverflow.com/q/35157844/4626813 - Expose contentType header to be send when retrieving the file/stream

Comments

  1. Gerry Cardinal III 2011-04-15

    In iOS, Ti.Media.AudioPlayer is missing many key features and has a few bugs as well. I have been working on them in Instant Automatic's fork and will be submitting a pull request to Appcelerator soon.

    For completeness, here is what I am working on:
    -ADD duration read-only property -ADD time property (for seeking) -ADD volume property -ADD next/prev and seeking remote control events -FIX play/pause remote controls don't work when using background audio -FIX changing the URL doesn't work (unless you stop first) -FIX progress events only fire for the first URL

    Let me know if I am missing anything.

  2. Ronnie Swietek 2011-04-15

    It is missing many things..another one is seek definitely. What is Instant Automatic? I would love to see the features added

  3. Gerry Cardinal III 2011-04-15

    Instant Automatic is a mobile applications startup that I work for. We currently use Titanium to develop our applications.

    I have completed and tested all the work I described above and pushed it to our fork on Titanium: https://github.com/organizations/instantautomatic">https://github.com/organizations/instantautomatic

    I will be doing even more testing early next week and then I will submit the pull request to Appcelerator. I have no clue what their process is for responding to pull requests.

  4. Ronnie Swietek 2011-04-15

    whoa that is really cool! I haven't looked into the user submitted plugins for Ti yet. Any examples of how someone would use your new code? You write the plugin in obj-c right?

  5. Gerry Cardinal III 2011-04-15

    Titanium does offer support for custom modules and we have developed some of these for our projects, but this is not a custom module. I have made these changes to Titanium itself (specifically, Ti.Media.AudioPlayer). I will be submitting a pull request with updates to the Kitchen Sink that showcase all of the new functionality.

    Both Titanium and custom modules (for iOS) are written in Objective-C.

    Feel free to clone or fork the Instant Automatic fork of Titanium and play with the new features.

  6. Stefan Schleich 2011-09-14

    I've just tested Gerry's changes to the AudioPlayer and they work pretty well! Is there a chance his changes get merged into the official mobile SDK? Gerry, thanks for the great work!
  7. Daniel Sefton 2013-02-26

    Hi Gerry, Did you manage to submit a pull request for this? We'd really appreciate it if you did, or if you already have a link would be great. Thanks! New URL where the commits can be found is here: https://github.com/instantautomatic/titanium_mobile/tree/master/iphone/Classes/AudioStreamer
  8. Juan Pablo Gonzalez Barrientos 2015-05-14

    Does someone has a workaround to "setTime()" method for IOS. Thank you!
  9. Jason Priebe 2015-05-14

    I wish. I was just looking all over the net for a third party audio player module for ios. I found some for android, but none for ios. Maybe it would be possible to pull the code from the titanium audio player into a new module and add Gerry's changes. I might try that for the next revision of our app.
  10. kosso 2015-08-06

    While trying to implement an audio player, I've also come against the lack of functionality listed in this issue when it comes to providing a viable product to play remote audio. One of the missing methods is a 'seek' (setTime). Bizarrely the AudioStreamerCUR.m currently used in the Titanium SDK already contains a seekToTime:time method but this has yet to be implemented. The reason that I need a seek is to overcome an issue which occurs when you try and pause a streaming mp3 url with Ti.Media.audioPlayer. What I found was that after resuming the paused audio, the STOPPING and STOPPED events will fire after a few seconds, ending the audio before it should. As if some data in the audio buffer has just been *forgotten*. So, I wanted to try and take a note of the current progress time when paused, then instead of just 'start'ing the playback again, I'd seek to the paused time and continue playback. (This does require the remote url to support Partial Content, since that's how seekToTime works.) During the past few days research on the matter, I found a module which employs the same seekToTime method from Matt Gallagher's AudioStreamer library. It does work, but has some glitches. https://github.com/atsusy/tiaudiostreaming The trouble is, is that the versions being used by this module *and* the Ti SDK are woefully out of date. The Github Network Graph of the AudioStreamer project [ https://github.com/mattgallagher/AudioStreamer/network ] shows many years of improvements. The furthest being Alex Crichton's https://github.com/alexcrichton/AudioStreamer where much mode modern methods are employed and many deprecations removed. (AudioStreamer was written before Apple even released the iPhone 3GS, in 2008! ;) ) The latest version on his branch also has a host of new features, such as metadata from ShoutCast servers, ID3 tags, etc. After even further research, I've also found that maybe a solution with AVFoundation/AVPlayer might be worth a shot. I'm going to attempt to build a module (and I don't *do* Objective-C ;) ) and see how I get on. K
  11. kosso 2015-08-09

    If anyone's interested, here's a stab I've had at building a module based on AVPlayer to try and replicate/replace/update the Ti.Media.audioPlayer. It's a bit shoddy and thrown together by someone who doesn't quite know what he's doing, but it's a start and it works. ;) It provides seek and speed (rate) methods too. https://github.com/kosso/TiAVPlayer
  12. Shawn Lan 2015-12-30

    Hi Kosso, I started using your module. It works great. Now I want to try your android module: https://github.com/kosso/tiandroidaudioplayer and hope it's in parity with https://github.com/kosso/TiAVPlayer so that I can re-use my code. But looks like it doesn't. For example, the debug tells me it doesn't have seekThenPlay(). Is it incomplete? Or did I miss anything? Thanks a lot!
  13. kosso 2015-12-30

    Hi, Probably best to keep this discussion on GitHub but a) Thanks! ;) and b) you should be able to use audioPlayer.seek(new_ms); where audioPlayer refers to either the iOS or Android module and it should work (and play) and set the time in ms. I have a feeling I didn't finish up the seekComplete event on both as I didn't need it in the app I was working on. But mostly, everything works fine across both platforms for live radio streams and remote audio urls (mp3, m4a, etc). Cheers!
  14. Brad Ball 2016-01-12

    any update on this? Being able to seek/scrub to a specific position/time is basic functionality that any audio player should be able to handle.
  15. Patrick Mounteney 2016-02-03

    Simply being able to pass in a content-type in the Ti AudioStreamer constructor would be a great help. I've hacked the AudioStreamer to recognise an AAC extension so it will trigger kAudioFileAAC_ADTSType, but as there area fair number of different url schemes out there, and given that the content-type (in my case) is known, it's cleaner to pass it in the Ti constructor. Unfortunately my Objective-C skills are minimal and I have to lie down in a dark room after even the simplest hack. So my addition to the original feature requests (of several years ago) would be a content-type property.
  16. Hans Knöchel 2018-01-13

    Considered to be added as part of TIMOB-24909. *EDIT*: - (Already available) ADD duration read-only property - (Already available) ADD time property (for seeking) - (Already available) ADD volume property - (Added in the linked ticket, used via seekToTime) ADD next/prev and seeking remote control events - (Fixed as part of using AVPlayer) FIX play/pause remote controls don't work when using background audio - (Fixed) FIX changing the URL doesn't work (unless you stop first) - (Fixed) FIX progress events only fire for the first URL
  17. Eric Merriman 2018-08-06

    Closing as a duplicate. If this is in error, please reopen.

JSON Source