/lib/titanium/mobile/media/AudioPlayer.hx

http://github.com/visup/haxe-titanium-api · Haxe · 143 lines · 43 code · 8 blank · 92 comment · 0 complexity · b3cec278139b5ff671a6d92868790192 MD5 · raw file

  1. package titanium.mobile.media;
  2. import titanium.mobile.core.Dispatcher;
  3. /**
  4. AudioPlayer class
  5. Documentation available at:
  6. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Media.AudioPlayer-object.html
  7. - namespace
  8. Titanium.Media.AudioPlayer
  9. - type
  10. object
  11. - subtype
  12. proxy
  13. - description
  14. The AudioPlayer object is returned by [[Titanium.Media.createAudioPlayer]] and is used for streaming audio to the device and low-level control of the audio playback.
  15. - since
  16. 0.9
  17. - platforms
  18. android, iphone, ipad
  19. - properties
  20. waiting[boolean]: returns boolean indicating if the playback is waiting for audio data from the network
  21. idle[boolean]: returns boolean indicating if the playback is idle
  22. playing[boolean]: returns boolean indicating if the playback is streaming audio
  23. paused[boolean]: returns boolean indicating if the playback is paused
  24. bitRate[double]: bit rate of the current playback stream
  25. progress[double]: returns the current playback progress. Will return zero if sampleRate has not yet been detected
  26. state[int]: returns int for the current state of playback
  27. url[string]: returns the url for the current playback
  28. allowBackground[boolean]: boolean to indicate if audio should continue playing even if Activity is paused (Android only as of 1.3.0)
  29. STATE_INITIALIZED[int]: current playback is in the initialization state
  30. STATE_STARTING[int]: current playback is in the starting playback state
  31. STATE_WAITING_FOR_DATA[int]: current playback is in the waiting for audio data from the network state
  32. STATE_WAITING_FOR_QUEUE[int]: current playback is in the waiting for audio data to fill the queue state
  33. STATE_PLAYING[int]: current playback is in the playing state
  34. STATE_BUFFERING[int]: current playback is in the buffering from the network state
  35. STATE_STOPPING[int]: current playback is in the stopping state
  36. STATE_STOPPED[int]: current playback is in the stopped state
  37. STATE_PAUSED[int]: current playback is in the paused state
  38. - methods
  39. setPaused: control the playback of the audio
  40. setUrl: change the url of the audio playback
  41. start: start playback
  42. stop: stop playback
  43. pause: pause playback
  44. stateDescription: convert a state into a textual description suitable for display
  45. - method : stateDescription, string
  46. - method : setPaused
  47. paused[boolean]: pass true to pause the current playback temporarily, false to unpause it
  48. - method : setUrl
  49. url[string]: the new url
  50. - events
  51. change: fired when the state of the playback changes
  52. progress: fired once per second with the current progress during playback
  53. - event : change
  54. state: current state of playback
  55. description: textual description of the state of playback
  56. - event : progress
  57. progress: current progress value
  58. **/
  59. typedef AudioPlayerChangeEvent =
  60. { > Event,
  61. description:String,
  62. state:Int
  63. }
  64. typedef AudioPlayerProgressEvent =
  65. { > Event,
  66. progress:Float
  67. }
  68. @:native("Titanium.Media.AudioPlayer")
  69. extern class AudioPlayer extends Dispatcher
  70. {
  71. // static constructor
  72. public inline static function create(?params:Dynamic):AudioPlayer
  73. return titanium.mobile.Media.createAudioPlayer(params)
  74. // events
  75. public static inline var CHANGE_EVENT = "change";
  76. public static inline var PROGRESS_EVENT = "progress";
  77. // constants
  78. public static var STATE_BUFFERING:Int;
  79. public static var STATE_INITIALIZED:Int;
  80. public static var STATE_PAUSED:Int;
  81. public static var STATE_PLAYING:Int;
  82. public static var STATE_STARTING:Int;
  83. public static var STATE_STOPPED:Int;
  84. public static var STATE_STOPPING:Int;
  85. public static var STATE_WAITING_FOR_DATA:Int;
  86. public static var STATE_WAITING_FOR_QUEUE:Int;
  87. // properties
  88. public var allowBackground:Bool;
  89. public var bitRate:Float;
  90. public var idle:Bool;
  91. public var paused:Bool;
  92. public var playing:Bool;
  93. public var progress:Float;
  94. public var state:Int;
  95. public var url:String;
  96. public var waiting:Bool;
  97. // methods
  98. public function pause():Void;
  99. public function setPaused(paused:Bool):Void;
  100. public function setUrl(url:String):Void;
  101. public function start():Void;
  102. public function stateDescription():String;
  103. public function stop():Void;
  104. }