You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the dRowAudio JUCE module
  4. Copyright 2004-13 by dRowAudio.
  5. ------------------------------------------------------------------------------
  6. dRowAudio is provided under the terms of The MIT License (MIT):
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in all
  14. copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. SOFTWARE.
  22. ==============================================================================
  23. */
  24. #ifndef __DROWAUDIO_AUDIOPICKER__
  25. #define __DROWAUDIO_AUDIOPICKER__
  26. #if JUCE_IOS || DOXYGEN
  27. //==============================================================================
  28. /**
  29. AudioPicker class
  30. An iOS-specific class that can be used for choosing audio files on
  31. supported devices.
  32. */
  33. class AudioPicker
  34. {
  35. public:
  36. /** Creates a default AudioPicker.
  37. Register yourself as a listener to this by inheriting from
  38. AudioPicker::Listener and then call the show method to display the picker.
  39. */
  40. AudioPicker();
  41. /** Destructor.
  42. */
  43. ~AudioPicker();
  44. //==============================================================================
  45. /** Shows the audio picker user interface.
  46. @param allowMultipleSelection If true multiple items can be selected.
  47. @param areaToPointTo On the iPad the picker is shown as a
  48. pop-over, this rectangle represents an area
  49. that the arrow of the pop-over should point to.
  50. */
  51. void show (bool allowMultipleSelection = false, Rectangle<int> areaToPointTo = Rectangle<int>());
  52. //==============================================================================
  53. /** This helper method returns the MPMediaItemPropertyAssetURL for a MPMediaItem
  54. such as those passed to Listener::audioPickerFinished.
  55. To keep the obj-C code behind the scenes the argument is a void* but should
  56. be a valid MPMediaItem. A String is returned for ease which can then be
  57. passed to an IOSAudioConverter.
  58. @returns AVAssetUrl String
  59. @see IOSAudioConverter
  60. */
  61. static String mpMediaItemToAvassetUrl (void* mpMediaItem);
  62. //==============================================================================
  63. /** A class for receiving callbacks from a AudioPicker.
  64. To be told when an audio picker changes, you can register a
  65. AudioPicker::Listener object using AudioPicker::addListener().
  66. @see AudioPicker::addListener, AudioPicker::removeListener
  67. */
  68. class Listener
  69. {
  70. public:
  71. /** Destructor. */
  72. virtual ~Listener() {}
  73. //==============================================================================
  74. /** Called when the audio picker has finished loading the selected track.
  75. This callback recieves an array of MPMediaItems. They are presented as
  76. void*'s to avoid Obj-C clashes.
  77. @see IOSAudioConverter, mpMediaItemToAvassetUrl, AudioPicker::audioPickerCancelled
  78. */
  79. virtual void audioPickerFinished (const Array<void*> mpMediaItems) = 0;
  80. /** Called when the audio picker has been canceled by the user.
  81. @see AudioPicker::audioPickerFinished
  82. */
  83. virtual void audioPickerCancelled() {}
  84. };
  85. /** Description
  86. @see removeListener
  87. */
  88. void addListener (Listener* newListener);
  89. /** Description
  90. @see addListener
  91. */
  92. void removeListener (Listener* listener);
  93. //==============================================================================
  94. /** @internal */
  95. void sendAudioPickerFinishedMessage (void* picker, void* info);
  96. /** @internal */
  97. void sendAudioPickerCancelledMessage (void* picker);
  98. private:
  99. //==============================================================================
  100. ListenerList<Listener> listeners;
  101. //==============================================================================
  102. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPicker);
  103. };
  104. #endif
  105. #endif // __DROWAUDIO_AUDIOPICKER__