直接贴源码吧,也没有很复杂
@interface PlayView : UIView
@property(nonatomic,strong)AVPlayer *player;
@property(nonatomic,strong)UIView *bottom;
@property(nonatomic,strong)AVPlayerItem *playerItem;
@property(nonatomic,strong)UISlider *slider;
- (id)initWithFrame:(CGRect)frame WithVideoStr:(NSString *)videoStr;
- (void)PlayOrPause;
@end
//
// PlayView.m
// AVPlayerDemo
//
// Created by 王颜龙 on 14-2-25.
// Copyright (c) 2014年 longyan. All rights reserved.
//
#import "PlayView.h"
static void *PlayViewCMTimeValue = &PlayViewCMTimeValue;
static void *AVPlayerDemoPlaybackViewControllerStatusObservationContext = &AVPlayerDemoPlaybackViewControllerStatusObservationContext;
@implementation PlayView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (id)initWithFrame:(CGRect)frame WithVideoStr:(NSString *)videoStr{
self = [super init];
if (self) {
self.frame = frame;
NSURL *sourceMovieURL = [NSURL fileURLWithPath:videoStr];
AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:sourceMovieURL options:nil];