小编Ale*_*nko的帖子

从AVFullScreenViewController iOS 8获取媒体链接

我想在某些内容开始播放时尝试获取视频链接(例如任何YouTube视频).

首先我抓住视频开始播放

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoStarted:) name:@"UIWindowDidBecomeVisibleNotification" object:nil];
Run Code Online (Sandbox Code Playgroud)

然后延迟尝试获取链接

-(void)videoStarted:(NSNotification *)notification
{
    NSLog(@"notification dic = %@", [notification userInfo]);
    [self performSelector:@selector(detectModal) withObject:nil afterDelay:2.5f];
}

-(void)detectModal
{
    CUViewController *controller = (CUViewController *)[appDelegate.window rootViewController].presentedViewController;
    NSLog(@"Presented modal = %@", [appDelegate.window rootViewController].presentedViewController);
    if(controller && [controller respondsToSelector:@selector(item)])
    {
        id currentItem = [controller item];
        if(currentItem && [currentItem respondsToSelector:@selector(asset)])
        {
            AVURLAsset *asset = (AVURLAsset *)[currentItem asset];
            if([asset respondsToSelector:@selector(URL)] && asset.URL)
                [self newLinkDetected:[[asset URL] absoluteString]];
            NSLog(@"asset find = %@", asset);
        }
    }
    else
    {
        for (UIWindow *window in [UIApplication …
Run Code Online (Sandbox Code Playgroud)

objective-c ios avplayer

8
推荐指数
1
解决办法
747
查看次数

标签 统计

avplayer ×1

ios ×1

objective-c ×1