VLCMediaList.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*****************************************************************************
  2. * VLCMediaList.h: VLCKit.framework VLCMediaList header
  3. *****************************************************************************
  4. * Copyright (C) 2007 Pierre d'Herbemont
  5. * Copyright (C) 2015 Felix Paul Kühne
  6. * Copyright (C) 2007, 2015 VLC authors and VideoLAN
  7. * $Id$
  8. *
  9. * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU Lesser General Public License as published by
  13. * the Free Software Foundation; either version 2.1 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * along with this program; if not, write to the Free Software Foundation,
  23. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  24. *****************************************************************************/
  25. #import <Foundation/Foundation.h>
  26. #import "VLCMedia.h"
  27. /**
  28. * notification name if a list item was added
  29. */
  30. extern NSString *const VLCMediaListItemAdded;
  31. /**
  32. * notification name if a list item was deleted
  33. */
  34. extern NSString *const VLCMediaListItemDeleted;
  35. @class VLCMedia;
  36. @class VLCMediaList;
  37. /**
  38. * VLCMediaListDelegate
  39. */
  40. @protocol VLCMediaListDelegate
  41. @optional
  42. /**
  43. * delegate method triggered when a media was added to the list
  44. *
  45. * \param aMediaList the media list
  46. * \param media the media object that was added
  47. * \param index the index the media object was added at
  48. */
  49. - (void)mediaList:(VLCMediaList *)aMediaList mediaAdded:(VLCMedia *)media atIndex:(NSUInteger)index;
  50. /**
  51. * delegate method triggered when a media was removed from the list
  52. *
  53. * \param aMediaList the media list
  54. * \param index the index a media item was deleted at
  55. */
  56. - (void)mediaList:(VLCMediaList *)aMediaList mediaRemovedAtIndex:(NSUInteger)index;
  57. @end
  58. /**
  59. * VLCMediaList
  60. */
  61. @interface VLCMediaList : NSObject
  62. /**
  63. * initializer with a set of VLCMedia instances
  64. * \param array the NSArray of VLCMedia instances
  65. * \return instance of VLCMediaList equipped with the VLCMedia instances
  66. * \see VLCMedia
  67. */
  68. - (instancetype)initWithArray:(NSArray *)array;
  69. /* Operations */
  70. /**
  71. * lock the media list from being edited by another thread
  72. */
  73. - (void)lock;
  74. /**
  75. * unlock the media list from being edited by another thread
  76. */
  77. - (void)unlock;
  78. /**
  79. * add a media to a read-write list
  80. *
  81. * \param media the media object to add
  82. * \return the index of the newly added media
  83. * \note this function silently fails if the list is read-only
  84. */
  85. - (NSUInteger)addMedia:(VLCMedia *)media;
  86. /**
  87. * add a media to a read-write list at a given position
  88. *
  89. * \param media the media object to add
  90. * \param index the index where to add the given media
  91. * \note this function silently fails if the list is read-only
  92. */
  93. - (void)insertMedia:(VLCMedia *)media atIndex:(NSUInteger)index;
  94. /**
  95. * remove media at position index and return true if the operation was successful.
  96. * An unsuccessful operation occurs when the index is greater than the medialists count
  97. *
  98. * \param index the index of the media to remove
  99. * \return boolean result of the removal operation
  100. * \note this function silently fails if the list is read-only
  101. */
  102. - (BOOL)removeMediaAtIndex:(NSUInteger)index;
  103. /**
  104. * retrieve a media from a given position
  105. *
  106. * \param index the index of the media you want
  107. * \return the media object
  108. */
  109. - (VLCMedia *)mediaAtIndex:(NSUInteger)index;
  110. /**
  111. * retrieve the position of a media item
  112. *
  113. * \param media the media object to search for
  114. * \return The lowest index of the provided media in the list
  115. * If media does not exist in the list, returns NSNotFound.
  116. */
  117. - (NSUInteger)indexOfMedia:(VLCMedia *)media;
  118. /* Properties */
  119. /**
  120. * count number of media items in the list
  121. * \return the number of media objects
  122. */
  123. @property (readonly) NSInteger count;
  124. /**
  125. * delegate property to listen to addition/removal events
  126. */
  127. @property (weak, nonatomic) id delegate;
  128. /**
  129. * read-only property to check if the media list is writable or not
  130. * \return boolean value if the list is read-only
  131. */
  132. @property (readonly) BOOL isReadOnly;
  133. @end