在我的应用程序中,我有像Facebook一样的时间轴,并希望以facebook的方式实现自动播放.每当用户停止在UITableViewCell内的视频帖子上滚动时,我就可以播放视频,但播放问题的视频需要5-10秒.
我需要专家指导如何预先缓冲来自网址的视频至少5秒,以便为用户提供更好的体验,或者在3g网络上立即从URL播放视频的其他方式.用户可能会发布100个视频.
我无法找到哪个类在播放时缓冲视频AVURLAsset,AVPlayerItem或AVPlayer.
我正在加载AVURLAsset loadValuesAsynchronouslyForKeys并创建AVPlayerItems然后保存到NSDictionary for URL Key.以下是我的代码.出于安全原因,URL在15分钟后过期.
-(void)setContentURL:(NSURL *)contentURL
{
if (contentURL)
{
[self.moviePlayer replaceCurrentItemWithPlayerItem:nil];
[_activityIndicator startAnimating];
__block AVPlayerItem *playerItem=[_appDelegate.dictAVPlayerItems objectForKey:[contentURL.absoluteString stringByAppendingString:self.postIdOrBlogId]];
if (!playerItem)
{
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:contentURL options:nil];
NSArray *keys = [NSArray arrayWithObject:@"playable"];
[asset loadValuesAsynchronouslyForKeys:keys completionHandler:^()
{
NSLog(@"keys %@", keys);
[self checkAssestStatus:asset];
if (asset==nil)return ;
playerItem = [AVPlayerItem playerItemWithAsset:asset];
[_appDelegate.dictAVPlayerItems setObject:playerItem forKey:[contentURL.absoluteString stringByAppendingString:self.postIdOrBlogId]];
dispatch_async(dispatch_get_main_queue(),
^{
[self addPlayerItem:playerItem isNewAsset:NO];
});
}];
_contentURL = contentURL;
}
else
[self addPlayerItem:playerItem isNewAsset:YES];
}
}
-(void)checkAssestStatus:(AVURLAsset*)asset
{
NSError *error = …Run Code Online (Sandbox Code Playgroud) 下面是我的代码崩溃
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
Run Code Online (Sandbox Code Playgroud)
我想设置字体请帮帮我谢谢.
+(void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect
{
// CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
// Prepare the text using a Core Text Framesetter
NSAttributedString *stringRef=[[[NSAttributedString alloc]initWithString:textToDraw attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:12.0],(NSString*)kCTFontAttributeName, nil]]autorelease];
CFAttributedStringRef currentText =(__bridge CFAttributedStringRef)stringRef;
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);// at this Line it giving me EXC_BAD_ACCESS
CGMutablePathRef framePath = CGPathCreateMutable();
CGPathAddRect(framePath, NULL, frameRect);
CFRange currentRange = CFRangeMake(0, 0);
CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
CGPathRelease(framePath);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity);
CGContextTranslateCTM(currentContext, 0, frameRect.origin.y*2);
CGContextScaleCTM(currentContext, 1.0, -1.0);
CTFrameDraw(frameRef, currentContext); …Run Code Online (Sandbox Code Playgroud) 
我有NSData对象中的所有数据,但我不知道如何创建将以此格式显示的pdf.主要问题是产品没有固定的内容大小,取决于客户,他/她购买的数量会越来越多.
我不想像以下格式那样制作uiview,因为如果这样做,那么如何以.png格式捕获整个uitableview.
请给出如何为以下格式创建pdf的逻辑.万分感谢!
我有这样的字符串 @"Root/dbo-NewsLocation/Item 1/dbo-Relator-test/Item 1/Item 1"
当用户点击后退按钮时,我需要删除上面字符串末尾的@"/ Item1".
我无法删除@"Item1"如果我stringByReplacingOccuranceOfString使用下面的代码执行此操作,则使用以下代码删除所有@"Item1".
NSString *str1=self.lblCIPath.text;
NSRange range = [str1 rangeOfString:@"/" options: NSBackwardsSearch];
NSString *newString = [str1 substringFromIndex:(range.location)];
self.lblCIPath.text=[self.lblCIPath.text stringByReplacingOccurrencesOfString:newString withString:@""];
Run Code Online (Sandbox Code Playgroud)
我会感激,如果任何人都可以建议我删除最后的方式componentPath从NSString.