2

I'm having a small issue. I'd like to receive all touches on the screen and for each one spawn a new video. The problem is that once a video is placed then it intercepts the touch points. I tried various values to go in locationInView but without any luck so far. Am I looking in the right place?

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    CGPoint pointOnScreen = [[touches anyObject] locationInView:self.view];

    C4Movie *player = [C4Movie movieNamed:@"inception.mov"];
    player.shouldAutoplay = YES;
    player.loops = YES;
    player.center = pointOnScreen;
    [self.canvas addMovie:player];

 }
 @end
Adam Tindale
  • 1,239
  • 10
  • 26

2 Answers2

3

Try setting the userInteractionEnabled property of each video screen (assuming it is held in some sort of UIView) to NO - that way, touch events will pass through it and continue to be received by your handler.

Chris McGrath
  • 1,936
  • 16
  • 17
3

Yes, you're looking in the right place, and Chris has it right about user interaction. You should try:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint pointOnScreen = [[touches anyObject] locationInView:self.view];
    C4Movie *player = [C4Movie movieNamed:@"inception.mov"];
    player.shouldAutoplay = YES;
    player.loops = YES;
    player.center = pointOnScreen;
    player.userInteractionEnabled = NO;
    [self.canvas addMovie:player];
}

However you're going to run into an issue with adding videos. Unfortunately, iOS / hardware only lets you have 4 video pipelines running at one time so you'll hit that pretty quickly.

If you want to add things to the screen as you touch and drag your finger, then you could also do the above code inside of the following method:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    //work your magic here
}
C4 - Travis
  • 4,502
  • 4
  • 31
  • 56
  • The simulator lets me add as many as I like. I'll put it on hardware and see what happens. Beyond just tracking and killing the oldest instance, is there another way of dealing with this? I can imagine it might be possible with an OPENGL layer. – Adam Tindale Feb 01 '13 at 20:34
  • Do they all play?! If they do that would be awesome, can you post a gist with your project so I can check it out. You can have multiple opengl objects for sure, the limitation is actually with the AVFoundation pipeline. But, maybe everything's changed since I last thoroughly tested movies (in the summer!). – C4 - Travis Feb 01 '13 at 21:08
  • Yes. In the simulation they all play but I haven't tried on hardware yet. The link to the gist is in a comment in the original question. Is that the best place to put the link once the issue is solved or should I edit the original post? – Adam Tindale Feb 02 '13 at 02:48