【发布时间】:2017-03-03 12:53:31
【问题描述】:
我正在处理丰富的通知Notification Content Extension,并且能够成功加载images 和gif,如下图所示:
现在我正在尝试播放视频,我正在执行以下代码来播放它。
- (void)didReceiveNotification:(UNNotification *)notification {
//self.label.text = @"HELLO world";//notification.request.content.body;
if(notification.request.content.attachments.count > 0)
{
UNNotificationAttachment *Attachen = notification.request.content.attachments.firstObject;
NSLog(@"====url %@",Attachen.URL);
AVAsset *asset = [AVAsset assetWithURL:Attachen.URL];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.contentsGravity = AVLayerVideoGravityResizeAspect;
player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
playerLayer.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.VideoPlayerView.layer addSublayer:playerLayer];
[player play];
}
}
在 NSLog 中,我也获得了视频的文件 url。但这不会玩。如果有人有这种解决方案,请提供帮助。
谢谢。
【问题讨论】:
标签: ios objective-c push-notification apple-push-notifications rich-notifications