Skip to content

Commit

Permalink
refactor: use init instead of new
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Sep 30, 2024
1 parent 2a38f7a commit 93e3752
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Sources/MuxStatsGoogleIMAPlugin/MuxImaListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ - (id)initWithPlayerBinding:(MUXSDKPlayerBinding *)binding options:(MuxImaListen
}

- (void)setupAdViewData:(MUXSDKAdEvent *)event withAd:(IMAAd *)ad {
MUXSDKViewData *viewData = [MUXSDKViewData new];
MUXSDKAdData *adData = [MUXSDKAdData new];
MUXSDKViewData *viewData = [[MUXSDKViewData alloc] init];
MUXSDKAdData *adData = [[MUXSDKAdData alloc] init];
if (ad != nil) {

if ([_playerBinding getCurrentPlayheadTimeMs] < 1000) {
Expand Down Expand Up @@ -78,40 +78,40 @@ - (nullable MUXSDKAdEvent *)dispatchEvent:(IMAAdEventType)eventType
switch(eventType) {
case kIMAAdEvent_STARTED: {
if (_sendAdplayOnStarted) {
playbackEvent = [MUXSDKAdPlayEvent new];
playbackEvent = [[MUXSDKAdPlayEvent alloc] init];
[_playerBinding dispatchAdEvent: playbackEvent];
} else {
_sendAdplayOnStarted = YES;
}
playbackEvent = [MUXSDKAdPlayingEvent new];
playbackEvent = [[MUXSDKAdPlayingEvent alloc] init];
break;
}
case kIMAAdEvent_FIRST_QUARTILE: {
playbackEvent = [MUXSDKAdFirstQuartileEvent new];
playbackEvent = [[MUXSDKAdFirstQuartileEvent alloc] init];
break;
}
case kIMAAdEvent_MIDPOINT: {
playbackEvent = [MUXSDKAdMidpointEvent new];
playbackEvent = [[MUXSDKAdMidpointEvent alloc] init];
break;
}
case kIMAAdEvent_THIRD_QUARTILE: {
playbackEvent = [MUXSDKAdThirdQuartileEvent new];
playbackEvent = [[MUXSDKAdThirdQuartileEvent alloc] init];
break;
}
case kIMAAdEvent_SKIPPED: {
playbackEvent = [MUXSDKAdEndedEvent new];
playbackEvent = [[MUXSDKAdEndedEvent alloc] init];
break;
}
case kIMAAdEvent_COMPLETE: {
playbackEvent = [MUXSDKAdEndedEvent new];
playbackEvent = [[MUXSDKAdEndedEvent alloc] init];
break;
}
case kIMAAdEvent_PAUSE: {
playbackEvent = [MUXSDKAdPauseEvent new];
playbackEvent = [[MUXSDKAdPauseEvent alloc] init];
break;
}
case kIMAAdEvent_RESUME: {
playbackEvent = [MUXSDKAdPlayEvent new];
playbackEvent = [[MUXSDKAdPlayEvent alloc] init];
MUXSDKViewData *viewData = [[MUXSDKViewData alloc] init];
if ([_playerBinding getCurrentPlayheadTimeMs] < 1000) {
viewData.viewPrerollAdId = adData.adId;
Expand Down Expand Up @@ -154,7 +154,7 @@ - (nullable MUXSDKAdEvent *)dispatchEvent:(IMAAdEventType)eventType
}

- (void)dispatchError:(NSString *)message {
MUXSDKAdEvent *playbackEvent = [MUXSDKAdErrorEvent new];
MUXSDKAdEvent *playbackEvent = [[MUXSDKAdErrorEvent alloc] init];
[self setupAdViewData:playbackEvent withAd:nil];
[_playerBinding dispatchAdEvent:playbackEvent];
}
Expand All @@ -169,7 +169,7 @@ - (void)onContentPauseOrResume:(bool)isPause {
// TODO: This is for backward compatability. Callers should call one of the *AdRequest methods. Remove this check in the next major rev
[self dispatchAdRequestWithoutMetadata];
}
MUXSDKAdEvent *playbackEvent = [MUXSDKAdBreakStartEvent new];
MUXSDKAdEvent *playbackEvent = [[MUXSDKAdBreakStartEvent alloc] init];
[self setupAdViewData:playbackEvent withAd:nil];
[_playerBinding dispatchAdEvent: playbackEvent];

Expand All @@ -181,7 +181,7 @@ - (void)onContentPauseOrResume:(bool)isPause {
if (_isPictureInPicture) {
[_playerBinding setAdPlaying:NO];
}
playbackEvent = [MUXSDKAdBreakEndEvent new];
playbackEvent = [[MUXSDKAdBreakEndEvent alloc] init];
[self setupAdViewDataAndDispatchEvent: playbackEvent];
if (_usesServerSideAdInsertion) {
[_playerBinding dispatchPlay];
Expand Down Expand Up @@ -210,13 +210,13 @@ - (void)daiAdRequest:(IMAStreamRequest *)request {
}

- (void)dispatchAdRequestWithoutMetadata {
MUXSDKAdEvent* playbackEvent = [MUXSDKAdRequestEvent new];
MUXSDKAdEvent* playbackEvent = [[MUXSDKAdRequestEvent alloc] init];
[self setupAdViewDataAndDispatchEvent: playbackEvent];
}

- (void)dispatchAdRequestForAdTag:(NSString *_Nullable)adTagUrl {
MUXSDKAdEvent* playbackEvent = [MUXSDKAdRequestEvent new];
MUXSDKAdData* adData = [MUXSDKAdData new];
MUXSDKAdEvent* playbackEvent = [[MUXSDKAdRequestEvent alloc] init];
MUXSDKAdData* adData = [[MUXSDKAdData alloc] init];
if(adTagUrl) {
adData.adTagUrl = adTagUrl;
}
Expand Down

0 comments on commit 93e3752

Please sign in to comment.