Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am using QTMovieView and , sometimes, I get the following log and follow by an unknown selector exception. The program has options for users to set to show and hide controller of the QTMovieView. The SDK that the program is linking against is 10.7

"[StdMovieUISliderCell sliderType]: unrecognized selector sent to instance"

thanks for any help

share|improve this question
    
I'm also seeing this error... Its driving me nuts. Also can't seem to get my QTMovieView controls to size to the full width of the QTMovieView. No matter the size or ratio I see about 10-30 pixels of space to the right of the controls, where the FF and RWD buttons usually are... This must be related... – Praveen Sharma Jun 14 '12 at 19:27
    
I had a view loaded from nib which used "AutoLayout". Once I unchecked the "AutoLayout", the problem has gone away. But I really didn't know why – user566822 Jun 15 '12 at 2:24
    
I can confirm this. I had a QTMovieView loaded from a nib, and whenever I called setMovie: on it, it crashed with this exception. Once I turned AutoLayout off in the nib, it worked fine. – gyim Jul 5 '12 at 7:26

This looks like a bug that was introduced in OS X Mountain Lion 10.8 (Edit: there are also reports on OS X 10.7, see comments below) . I guess that QTMovieView will get deprecated in one of the next major OS X releases. The best solution is to move to AV Foundation (AVPlayer and the corresponding AVPlayerLayer class). Apple has some documentation about playing back assets using this framework.

That said, if you can’t update to AV Foundation or you can’t turn off Auto Layout, you still can fix this issue by adding the missing methods dynamically during runtime to the StdMovieUISliderCell class. Make sure to add the Objective C runtime header file and to add the methods as early as possible (e.g. + (void)load in your application delegate). For App Store static analyzer rejection foo reasons, it’s also safe to add some simple encoding to the class name like rot13.

// Make sure that we have the right headers.
#import <objc/runtime.h>

// The selectors should be recognized by class_addMethod().
@interface NSObject (SliderCellBugFix)

- (NSSliderType)sliderType;
- (NSInteger)numberOfTickMarks;

@end

// Add C implementations of missing methods that we’ll add
// to the StdMovieUISliderCell class later.
static NSSliderType SliderType(id self, SEL _cmd)
{
  return NSLinearSlider;
}

static NSInteger NumberOfTickMarks(id self, SEL _cmd)
{
  return 0;
}

// rot13, just to be extra safe.
static NSString *ResolveName(NSString *aName)
{
  const char *_string = [aName cStringUsingEncoding:NSASCIIStringEncoding];
  NSUInteger stringLength = [aName length];
  char newString[stringLength+1];

  NSUInteger x;
  for(x = 0; x < stringLength; x++)
  {
    unsigned int aCharacter = _string[x];

    if( 0x40 < aCharacter && aCharacter < 0x5B ) // A - Z
      newString[x] = (((aCharacter - 0x41) + 0x0D) % 0x1A) + 0x41;
    else if( 0x60 < aCharacter && aCharacter < 0x7B ) // a-z
      newString[x] = (((aCharacter - 0x61) + 0x0D) % 0x1A) + 0x61;
    else  // Not an alpha character
      newString[x] = aCharacter;
  }
  newString[x] = '\0';

  return [NSString stringWithCString:newString encoding:NSASCIIStringEncoding];
}

// Add both methods if they aren’t already there. This should makes this
// code safe, even if Apple decides to implement the methods later on.
+ (void)load
{
  Class MovieSliderCell = NSClassFromString(ResolveName(@"FgqZbivrHVFyvqrePryy"));

  if (!class_getInstanceMethod(MovieSliderCell, @selector(sliderType)))
  {
    const char *types = [[NSString stringWithFormat:@"%s%s%s",
      @encode(NSSliderType), @encode(id), @encode(SEL)] UTF8String];
    class_addMethod(MovieSliderCell, @selector(sliderType),
      (IMP)SliderType, types);
  }
  if (!class_getInstanceMethod(MovieSliderCell, @selector(numberOfTickMarks)))
  {
    const char *types = [[NSString stringWithFormat: @"%s%s%s",
      @encode(NSInteger), @encode(id), @encode(SEL)] UTF8String];
    class_addMethod(MovieSliderCell, @selector(numberOfTickMarks),
      (IMP)NumberOfTickMarks, types);
  }
}

I made two assumptions while implementing both methods:

  1. A movie view can only have a linear slider, not a circular one.
  2. A movie view won’t have tick marks.

The latter could be a problem if your movie has chapters, but I don’t know how they are handled, because I don’t need or use them.

share|improve this answer
1  
Apple does a simple string search for private API. I am mostly lazy if special private API hacks are needed and build them with NSString stringWithFormat:@"_pri%@thod", @"vateMe. Never got rejected for that :) – steipete Sep 10 '12 at 16:51
    
That’s even better than my rot13 solution. Thanks for sharing your experience. – Rafael Sep 10 '12 at 17:02
1  
It wasn't introduced in 10.8. I'm building and running on 10.7.5 and seeing it. – Peter Hosey Jan 1 '13 at 8:39

I had the same problem if I tried to use setMovie: with AutoLayout on. An update to Xcode 4.4.1 fixed the problem.

share|improve this answer
    
I'm using Xcode 4.5.2 on 10.7.5 and having this problem. – Peter Hosey Jan 1 '13 at 8:45

i know it's a fairly old post, but for others out there, i had the same problem, i've just deactivated the cocoa autolayout for the xib file containing the QTMovieView and it worked like it should have.

i'm currently working with xcode 4.5.2 under OSX 10.7.4

share|improve this answer
    
This was what I did, as well. (And then I switched to AVPlayer, so now I could probably turn Auto Layout back on if I saw a need.) – Peter Hosey Apr 8 '13 at 20:46

Fixed this issue by adding empty updateConstraintsForSubtreeIfNeeded method in QtMovieView subclass.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.