Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting SCImageView on Player stops playback. #286

Closed
MMasterson opened this issue Mar 10, 2016 · 11 comments
Closed

Setting SCImageView on Player stops playback. #286

MMasterson opened this issue Mar 10, 2016 · 11 comments

Comments

@MMasterson
Copy link

I've been trying to implement filters, but I am having several issues. The code below should work, but there is 0 playback.

    [_playerView setFrame:[[self containerView ] bounds]];
    [[ _playerView player] setItemByAsset:[[self recordSession] assetRepresentingSegments]];
    [[ _playerView playerLayer] setFrame:[[self containerView ] bounds]];
    [[ _playerView playerLayer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];

    [[ _playerView player] setDelegate:self];
    [[ _playerView player] setLoopEnabled:YES];
    [[ _playerView player] beginSendingPlayMessages];

    [[ _playerView player] play];

    SCFilterImageView *filterView = [[SCFilterImageView alloc] initWithFrame:[[self containerView ] bounds]];
    filterView.filter = [SCFilter filterWithCIFilterName:@"CIPhotoEffectInstant"];
 [[_playerView player] setSCImageView:filterView];



when I remove
[[_playerView player] setSCImageView:filterView];

The video plays...

Anyone have any luck on gettings Filters working with SCRecorder?

@MMasterson
Copy link
Author

I've added
[_playerView insertSubview:filterView belowSubview:_playerControlsView];

and moved

[[ _playerView player] setItemByAsset:[[self recordSession] assetRepresentingSegments]];

and it is now working intermittently. Takes a few times to get the video to actually play through the filter.

The end goal is to use the Swipe View but I've had 0 luck with that.

_ iOS9_

@shiweige
Copy link

@MMasterson Maybe I met the same problem, could you please describe what is _playerView and _playerControlsView in your code?

@MMasterson
Copy link
Author

sure @shiweige

_playerView is an outlet of SCVideoPlayerView on the story board and _playerControlsView is an outlet of a UIView that holds the play button, next and cancel button for the camera.

@glm4
Copy link

glm4 commented Mar 11, 2016

@MMasterson you don't need the SCplayerView since your renderer will be the SCFilterImageView or your future SwipeableFilterVIew.
First, initialize your scPlayer.

self.scPlayer.shouldSuppressPlayerRendering = NO; [self setupFilterSwitcher]; self.scPlayer.SCImageView = self.swipeableFilterView;

Then
- (void)setupFilterSwitcher { self.swipeableFilterView.filters = <your filters>; self.swipeableFilterView.delegate = self; //If you need it self.swipeableFilterView.contentMode = UIViewContentModeScaleAspectFit; //or whatever }

my self.swipeableFilterView is an outlet from my storyboard.
That should do it.

@MMasterson
Copy link
Author

@sherm4n90 I've made the appropriate changes

Changed my SCplayerView to a SCSwipeableFilterView and reconnected it as an outlet named swipeableFilterView

in my viewDidLoad
I've added

  if(_player == nil){
        _player = [[SCPlayer alloc] init];
    }

I've added your method

- (void)setupFilterSwitcher {
    self.swipeableFilterView.filters = @[[SCFilter filterWithCIFilterName:@"CIPhotoEffectNoir"],
                                         [SCFilter filterWithCIFilterName:@"CIPhotoEffectChrome"],
                                         [SCFilter filterWithCIFilterName:@"CIPhotoEffectInstant"],
                                         [SCFilter filterWithCIFilterName:@"CIPhotoEffectTonal"],
                                         [SCFilter filterWithCIFilterName:@"CIPhotoEffectFade"]];
    self.swipeableFilterView.delegate = self;
    //If you need it
    self.swipeableFilterView.contentMode = UIViewContentModeScaleAspectFit; //or whatever
}

in my viewDidAppear
I've added

    _player.shouldSuppressPlayerRendering = NO;
    [self setupFilterSwitcher];
    _player.SCImageView = self.swipeableFilterView;

and it does play the video although, the swipe does not work - as in the filters do not change

@glm4
Copy link

glm4 commented Mar 11, 2016

@MMasterson did you try the - (void)swipeableFilterView:(SCSwipeableFilterView *__nonnull)swipeableFilterView didScrollToFilter:(SCFilter *__nullable)filter protocol method? This will tell you if the scrolling through filters is working.

Edited: also you may need:
- (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; [self.swipeableFilterView setNeedsDisplay]; }

@MMasterson
Copy link
Author

@sherm4n90 - It is not being called - but can't seem to figure out why.

Is there a User Interaction field I have to enable programmatically?

@MMasterson
Copy link
Author

@sherm4n90 even with your edit, no luck on getting the gesture to fire.

@glm4
Copy link

glm4 commented Mar 11, 2016

@MMasterson mm, nothing to add, maybe you have some view covering the swipeableView.

@MMasterson
Copy link
Author

@sherm4n90 yup.. just double checked, had a view over the swipeView...

Thank's so much for your help with the set up!

@glm4
Copy link

glm4 commented Mar 11, 2016

@MMasterson great! glad to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants