VLCMediaLibrary.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*****************************************************************************
  2. * VLCMediaLibrary.m: VLCKit.framework VLCMediaLibrary implementation
  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 <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_exception_t p_e;
  45. libvlc_exception_init( &p_e );
  46. libvlc_media_library_load( mlib, &p_e );
  47. catch_exception( &p_e );
  48. allMedia = nil;
  49. }
  50. return self;
  51. }
  52. - (void)dealloc
  53. {
  54. [allMedia release];
  55. libvlc_media_library_release(mlib);
  56. mlib = nil; // make sure that the pointer is dead
  57. [super dealloc];
  58. }
  59. - (VLCMediaList *)allMedia
  60. {
  61. if( !allMedia )
  62. {
  63. libvlc_media_list_t * p_mlist = libvlc_media_library_media_list( mlib, NULL );
  64. allMedia = [[VLCMediaList mediaListWithLibVLCMediaList:p_mlist] retain];
  65. libvlc_media_list_release(p_mlist);
  66. }
  67. return allMedia;
  68. }
  69. @end