VLCStreamSession.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // VLCStreamSession.m
  3. // VLCKit
  4. //
  5. // Created by Pierre d'Herbemont on 1/12/08.
  6. // Copyright 2008 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "VLCStreamSession.h"
  9. #import "VLCLibVLCBridging.h"
  10. @implementation VLCStreamSession
  11. @synthesize media=originalMedia;
  12. @synthesize streamOutput;
  13. + (id)streamSession
  14. {
  15. return [[[self alloc] init] autorelease];
  16. }
  17. - (void)startStreaming;
  18. {
  19. [self play];
  20. }
  21. - (void)play;
  22. {
  23. NSString * libvlcArgs;
  24. if( self.drawable )
  25. {
  26. libvlcArgs = [NSString stringWithFormat:@"duplicate{dst=display,dst=\"%@\"}",[streamOutput representedLibVLCOptions]];
  27. }
  28. else
  29. {
  30. libvlcArgs = [streamOutput representedLibVLCOptions];
  31. }
  32. [super setMedia: [VLCMedia mediaWithMedia:originalMedia andLibVLCOptions:
  33. [NSDictionary dictionaryWithObject: libvlcArgs
  34. forKey: @"sout"]]];
  35. [super play];
  36. }
  37. + (NSSet *)keyPathsForValuesAffectingDescription
  38. {
  39. return [NSSet setWithObjects:@"isCompleted", @"state", nil];
  40. }
  41. - (NSString *)description
  42. {
  43. if([self isComplete])
  44. return @"Done.";
  45. else if([self state] == VLCMediaPlayerStateError)
  46. return @"Error while Converting. Open Console.app to diagnose.";
  47. else
  48. return @"Converting...";
  49. }
  50. + (NSSet *)keyPathsForValuesAffectingIsComplete
  51. {
  52. return [NSSet setWithObjects:@"playing", @"state", @"position", nil];
  53. }
  54. - (BOOL)isComplete
  55. {
  56. return ([self position] == 1.0 || [self state] == VLCMediaPlayerStateEnded || ([self state] == VLCMediaPlayerStateStopped && self.media));
  57. }
  58. @end