VLCMediaLibrary.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*****************************************************************************
  2. * VLCMediaLibrary.m: VLCKit.framework VLCMediaLibrary implementation
  3. *****************************************************************************
  4. * Copyright (C) 2007 Pierre d'Herbemont
  5. * Copyright (C) 2007 VLC authors and VideoLAN
  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 it
  11. * under the terms of the GNU Lesser General Public License as published by
  12. * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public License
  21. * along with this program; if not, write to the Free Software Foundation,
  22. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23. *****************************************************************************/
  24. #import <Cocoa/Cocoa.h>
  25. #import "VLCMediaLibrary.h"
  26. #import "VLCLibrary.h"
  27. #import "VLCLibVLCBridging.h"
  28. #include <vlc/libvlc.h>
  29. @implementation VLCMediaLibrary
  30. + (id)sharedMediaLibrary
  31. {
  32. static VLCMediaLibrary * sharedMediaLibrary = nil;
  33. if( !sharedMediaLibrary )
  34. {
  35. sharedMediaLibrary = [[VLCMediaLibrary alloc] init];
  36. }
  37. return sharedMediaLibrary;
  38. }
  39. - (id)init
  40. {
  41. if (self = [super init])
  42. {
  43. mlib = libvlc_media_library_new( [VLCLibrary sharedInstance]);
  44. libvlc_media_library_load( mlib );
  45. allMedia = nil;
  46. }
  47. return self;
  48. }
  49. - (void)dealloc
  50. {
  51. [allMedia release];
  52. libvlc_media_library_release(mlib);
  53. mlib = nil; // make sure that the pointer is dead
  54. [super dealloc];
  55. }
  56. - (VLCMediaList *)allMedia
  57. {
  58. if( !allMedia )
  59. {
  60. libvlc_media_list_t * p_mlist = libvlc_media_library_media_list( mlib );
  61. allMedia = [[VLCMediaList mediaListWithLibVLCMediaList:p_mlist] retain];
  62. libvlc_media_list_release(p_mlist);
  63. }
  64. return allMedia;
  65. }
  66. @end