VLCMedia.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*****************************************************************************
  2. * VLCMedia.h: VLCKit.framework VLCMedia header
  3. *****************************************************************************
  4. * Copyright (C) 2007 Pierre d'Herbemont
  5. * Copyright (C) 2007 the VideoLAN team
  6. * $Id$
  7. *
  8. * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23. *****************************************************************************/
  24. #import "VLCMediaList.h"
  25. #import "VLCTime.h"
  26. /* Meta Dictionary Keys */
  27. /**
  28. * Standard dictionary keys for retreiving meta data.
  29. */
  30. extern NSString * VLCMetaInformationTitle; /* NSString */
  31. extern NSString * VLCMetaInformationArtist; /* NSString */
  32. extern NSString * VLCMetaInformationGenre; /* NSString */
  33. extern NSString * VLCMetaInformationCopyright; /* NSString */
  34. extern NSString * VLCMetaInformationAlbum; /* NSString */
  35. extern NSString * VLCMetaInformationTrackNumber; /* NSString */
  36. extern NSString * VLCMetaInformationDescription; /* NSString */
  37. extern NSString * VLCMetaInformationRating; /* NSString */
  38. extern NSString * VLCMetaInformationDate; /* NSString */
  39. extern NSString * VLCMetaInformationSetting; /* NSString */
  40. extern NSString * VLCMetaInformationURL; /* NSString */
  41. extern NSString * VLCMetaInformationLanguage; /* NSString */
  42. extern NSString * VLCMetaInformationNowPlaying; /* NSString */
  43. extern NSString * VLCMetaInformationPublisher; /* NSString */
  44. extern NSString * VLCMetaInformationEncodedBy; /* NSString */
  45. extern NSString * VLCMetaInformationArtworkURL; /* NSString */
  46. extern NSString * VLCMetaInformationArtwork; /* NSImage */
  47. extern NSString * VLCMetaInformationTrackID; /* NSString */
  48. /* Notification Messages */
  49. /**
  50. * Available notification messages.
  51. */
  52. extern NSString * VLCMediaMetaChanged; //< Notification message for when the media's meta data has changed
  53. // Forward declarations, supresses compiler error messages
  54. @class VLCMediaList;
  55. @class VLCMedia;
  56. typedef enum VLCMediaState
  57. {
  58. VLCMediaStateNothingSpecial, //< Nothing
  59. VLCMediaStateBuffering, //< Stream is buffering
  60. VLCMediaStatePlaying, //< Stream is playing
  61. VLCMediaStateError, //< Can't be played because an error occured
  62. } VLCMediaState;
  63. /**
  64. * Informal protocol declaration for VLCMedia delegates. Allows data changes to be
  65. * trapped.
  66. */
  67. @protocol VLCMediaDelegate
  68. // TODO: SubItemAdded/SubItemRemoved implementation. Not sure if we really want to implement this.
  69. ///**
  70. // * Delegate method called whenever a sub item has been added to the specified VLCMedia.
  71. // * \param aMedia The media resource that has received the new sub item.
  72. // * \param childMedia The new sub item added.
  73. // * \param index Location of the new subitem in the aMedia's sublist.
  74. // */
  75. // - (void)media:(VLCMedia *)media addedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
  76. ///**
  77. // * Delegate method called whenever a sub item has been removed from the specified VLCMedia.
  78. // * \param aMedia The media resource that has had a sub item removed from.
  79. // * \param childMedia The sub item removed.
  80. // * \param index The previous location of the recently removed sub item.
  81. // */
  82. // - (void)media:(VLCMedia *)aMedia removedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
  83. /**
  84. * Delegate method called whenever the meta has changed for the receiver.
  85. * \param aMedia The media resource whose meta data has been changed.
  86. * \param oldValue The old meta data value.
  87. * \param key The key of the value that was changed.
  88. */
  89. - (void)media:(VLCMedia *)aMedia metaValueChangedFrom:(id)oldValue forKey:(NSString *)key;
  90. @end
  91. /**
  92. * Defines files and streams as a managed object. Each media object can be
  93. * administered seperately. VLCMediaPlayer or VLCMediaList must be used
  94. * to execute the appropriate playback functions.
  95. * \see VLCMediaPlayer
  96. * \see VLCMediaList
  97. */
  98. @interface VLCMedia : NSObject
  99. {
  100. void * p_md; //< Internal media descriptor instance
  101. NSURL * url; //< URL (MRL) for this media resource
  102. VLCMediaList * subitems; //< Sub list of items
  103. VLCTime * length; //< Cached duration of the media
  104. NSMutableDictionary * metaDictionary; //< Meta data storage
  105. id delegate; //< Delegate object
  106. BOOL isArtFetched; //< Value used to determine of the artwork has been preparsed
  107. BOOL areOthersMetaFetched; //< Value used to determine of the other meta has been preparsed
  108. BOOL isArtURLFetched; //< Value used to determine of the other meta has been preparsed
  109. VLCMediaState state; //< Current state of the media
  110. }
  111. /* Factories */
  112. /**
  113. * Manufactures a new VLCMedia object using the URL specified.
  114. * \param anURL URL to media to be accessed.
  115. * \return A new VLCMedia object, only if there were no errors. This object will be automatically released.
  116. * \see initWithMediaURL
  117. */
  118. + (id)mediaWithURL:(NSURL *)anURL;
  119. /**
  120. * Manufactures a new VLCMedia object using the path specified.
  121. * \param aPath Path to the media to be accessed.
  122. * \return A new VLCMedia object, only if there were no errors. This object will be automatically released.
  123. * \see initWithPath
  124. */
  125. + (id)mediaWithPath:(NSString *)aPath;
  126. /**
  127. * TODO
  128. * \param aName TODO
  129. * \return a new VLCMedia object, only if there were no errors. This object
  130. * will be automatically released.
  131. * \see initAsNodeWithName
  132. */
  133. + (id)mediaAsNodeWithName:(NSString *)aName;
  134. /* Initializers */
  135. /**
  136. * Initializes a new VLCMedia object to use the specified URL.
  137. * \param aPath Path to media to be accessed.
  138. * \return A new VLCMedia object, only if there were no errors.
  139. */
  140. - (id)initWithURL:(NSURL *)anURL;
  141. /**
  142. * Initializes a new VLCMedia object to use the specified path.
  143. * \param aPath Path to media to be accessed.
  144. * \return A new VLCMedia object, only if there were no errors.
  145. */
  146. - (id)initWithPath:(NSString *)aPath;
  147. /**
  148. * TODO
  149. * \param aName TODO
  150. * \return A new VLCMedia object, only if there were no errors.
  151. */
  152. - (id)initAsNodeWithName:(NSString *)aName;
  153. /**
  154. * Returns an NSComparisonResult value that indicates the lexical ordering of
  155. * the receiver and a given meda.
  156. * \param media The media with which to compare with the receiver.
  157. * \return NSOrderedAscending if the URL of the receiver precedes media in
  158. * lexical ordering, NSOrderedSame if the URL of the receiver and media are
  159. * equivalent in lexical value, and NSOrderedDescending if the URL of the
  160. * receiver follows media. If media is nil, returns NSOrderedDescending.
  161. */
  162. - (NSComparisonResult)compare:(VLCMedia *)media;
  163. /* Properties */
  164. /**
  165. * Receiver's delegate.
  166. */
  167. @property (assign) id delegate;
  168. /**
  169. * A VLCTime object describing the length of the media resource, only if it is
  170. * available. Use lengthWaitUntilDate: to wait for a specified length of time.
  171. * \see lengthWaitUntilDate
  172. */
  173. @property (retain, readonly) VLCTime * length;
  174. /**
  175. * Returns a VLCTime object describing the length of the media resource,
  176. * however, this is a blocking operation and will wait until the preparsing is
  177. * completed before returning anything.
  178. * \param aDate Time for operation to wait until, if there are no results
  179. * before specified date then nil is returned.
  180. * \return The length of the media resource, nil if it couldn't wait for it.
  181. */
  182. - (VLCTime *)lengthWaitUntilDate:(NSDate *)aDate;
  183. /**
  184. * Determines if the media has already been preparsed.
  185. */
  186. @property (readonly) BOOL isPreparsed;
  187. /**
  188. * The URL for the receiver's media resource.
  189. */
  190. @property (retain, readonly) NSURL * url;
  191. /**
  192. * The receiver's sub list.
  193. */
  194. @property (retain, readonly) VLCMediaList * subitems;
  195. /**
  196. * The receiver's meta data as a NSDictionary object.
  197. */
  198. @property (retain, readonly) NSDictionary * metaDictionary;
  199. /**
  200. * The receiver's state, such as Playing, Error, NothingSpecial, Buffering.
  201. */
  202. @property (readonly) VLCMediaState state;
  203. @end