Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

A signal equivalent to AVMakeRectWithAspectRatioInsideRect ? #73

@zakdances

Description

@zakdances

I've been constructing my own signal to pass a CGSize through AVFoundation's very useful AVMakeRectWithAspectRatioInsideRect function. Example:

self.videoScaledSizeSignal = [[RACSignal combineLatest:@[
    [RACAbleWithStart(self,player.currentItem.tracks) distinctUntilChanged] ,
    [RACAbleWithStart(self.maxSize) distinctUntilChanged]]
    reduce:^(NSArray *array,NSValue *maxSize){

         // If maxSize hasn't been set, just return a zero rect                                   
        CGSize videoScaledSize = CGSizeZero;
        if (CGSizeEqualToSize(maxSize.med_sizeValue, CGSizeZero)) {
                return MEDBox(videoScaledSize);
        }

        for (AVPlayerItemTrack *itemTrack in array) {
                  if ([itemTrack.assetTrack.mediaType isEqualToString:AVMediaTypeVideo]) {

                      CGSize naturalSize = itemTrack.assetTrack.naturalSize;
                      videoScaledSize = AVMakeRectWithAspectRatioInsideRect(naturalSize,  CGRectWithSize(maxSize.med_sizeValue)).size;

                      }

          }


          return MEDBox(videoScaledSize);
      }] filter:^BOOL(NSValue *videoScaledSize) {
            return !CGSizeEqualToSize(videoScaledSize.med_sizeValue, CGSizeZero);
   }];

I was going to submit a pull request for a RACSignal category containing a simplified version of my above signal, but there's a problem. AVMakeRectWithAspectRatioInsideRect requires AVFoundation, and I'm not sure it's a good idea to add a big dependency like that to RCL.

What would the best way be to add this functionality to RCL (or RAC)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions