VLCAudio.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*****************************************************************************
  2. * VLCAudio.m: VLCKit.framework VLCAudio implementation
  3. *****************************************************************************
  4. * Copyright (C) 2007 Faustino E. Osuna
  5. * Copyright (C) 2007 the VideoLAN team
  6. * $Id$
  7. *
  8. * Authors: Faustino E. Osuna <enrique.osuna # gmail.com>
  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 "VLCAudio.h"
  25. #import "VLCLibVLCBridging.h"
  26. /* Notification Messages */
  27. NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
  28. /* libvlc event callback */
  29. // TODO: Callbacks
  30. @implementation VLCAudio
  31. - (id)init
  32. {
  33. return nil;
  34. }
  35. - (id)initWithLibrary:(VLCLibrary *)aLibrary
  36. {
  37. if (![library audio] && (self = [super init]))
  38. {
  39. library = aLibrary;
  40. [library setAudio:self];
  41. }
  42. return self;
  43. }
  44. - (void)setMute:(BOOL)value
  45. {
  46. libvlc_audio_set_mute([library instance], value, NULL);
  47. }
  48. - (BOOL)isMuted
  49. {
  50. libvlc_exception_t ex;
  51. libvlc_exception_init(&ex);
  52. BOOL result = libvlc_audio_get_mute([library instance], &ex);
  53. catch_exception(&ex);
  54. return result;
  55. }
  56. - (void)setVolume:(int)value
  57. {
  58. if (value < 0)
  59. value = 0;
  60. else if (value > 200)
  61. value = 200;
  62. libvlc_audio_set_volume([library instance], value, NULL);
  63. }
  64. - (int)volume
  65. {
  66. libvlc_exception_t ex;
  67. libvlc_exception_init(&ex);
  68. int result = libvlc_audio_get_volume([library instance], &ex);
  69. catch_exception(&ex);
  70. return result;
  71. }
  72. @end