// PlayVedioController.m
// MiYaYoGa
//
// Created by zhangxiangguang on 12-1-10.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import "PlayVedioController.h"
#import "GungnirViewController.h"
#define URL @"http://pulati.trends.com.cn/source/miya/"
#define WINDOW [[UIApplication sharedApplication] keyWindow]
#define PAGEID @"20111226_"
#define APP_ID @"miya_"
#define APP_BTN @"btn_"
@implementation PlayVedioController
@synthesize root;
@synthesize controller;
@synthesize moviePlayer;
- (id) init {
if (self = [super init]) {
self.root = nil;
self.controller = nil;
self.moviePlayer = nil;
}
return self;
}
- (void) viewDidLoad {
[super viewDidLoad];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
//根视图
self.root = [[[UIView alloc] initWithFrame: WINDOW.frame] autorelease];
self.root.backgroundColor = [UIColor blackColor];
self.view = self.root;
//开机动画
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(finishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil ];
NSString *path = [[NSBundle mainBundle] pathForResource:@"trends" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
self.moviePlayer = [[[MPMoviePlayerController alloc]initWithContentURL:url ] autorelease];
self.moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.moviePlayer.view.frame = self.view.bounds;
if (self.moviePlayer) {
[self.view addSubview:self.moviePlayer.view];
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
[self.moviePlayer play];
}
}
/** 视频播放结束通知 */
- (void) finishedCallback: (NSNotification *) notification {
[[NSNotificationCenter defaultCenter] removeObserver: self name: MPMoviePlayerPlaybackDidFinishNotification object: nil];
[self.moviePlayer stop];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *str = [ud objectForKey:@"isFirst"];
NSLog(@"str is %@",str);
if(str == nil || [str length] == 0){
CourseViewController *courseViewController = [[[CourseViewController alloc] init ] autorelease];
[self.navigationController pushViewController:courseViewController animated:YES];
}else{
GungnirViewController *gungnirViewController = [[[GungnirViewController alloc] init ] autorelease];
[self.navigationController pushViewController:gungnirViewController animated:YES];
}
[pool drain];
pool = nil;
}
/** 设置导航条标题 */
- (void) setTopBarTitle: (NSString *) title{
}
/** 点击播放/暂停按钮更新按钮提示 */
- (void) updateBtnTitle: (NSString *) btnTitle {
}
/** pop选择器视图 */
- (void) popPickerView{
}
/** push选择器视图 */
- (void) pushPickerView{
}
/** push新视图显示到旧视图上 */
- (void) pushViewController: (UIViewController *) targetController barTitle: (NSString *) title{
}
/** push视频播放视图显示到旧视图上 */
- (void) pushViewPlayVedioController: (UIViewController *) targetController{
}
/** pop新视图显示旧视图 */
- (void) popViewController: (UIViewController *) targetController{
}
/** pop视频播放视图显示到旧视图上 */
- (void) popViewPlayVedioController: (UIViewController *) targetController previousController: (UIViewController *) previousController{
}
/** push新视图显示到旧视图上 */
- (void) presentViewController: (UIViewController *) targetController barTitle: (NSString *) title{
}
/** push新视图显示到旧视图上 */
- (void) dismissViewController: (UIViewController *) targetController barTitle: (NSString *) title{
}
/** 顶部视图的按钮显示/隐藏操作 */
- (void) topBarBtnShowOrHidden: (NSDictionary *) dictionary viewController: (UIViewController *) targetController{
}
/** 底部按钮视图的按钮显示/隐藏操作 */
- (void) btnBarBtnShowOrHidden: (NSDictionary *) dictionary viewController: (UIViewController *) targetController{
}
/** 底部视图显示/隐藏操作 */
- (void) bottomBarShowOrHidden: (NSDictionary *) dictionary viewController: (UIViewController *) targetController{
}
/** 返回按钮点击事件 */
- (void) backBtnClieckEvent{
}
- (void) didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void) viewDidUnload {
[super viewDidUnload];
}
- (void)dealloc {
[self.moviePlayer release];
self.moviePlayer = nil;
[self.controller release];
self.controller = nil;
[self.root release];
self.root = nil;
[super dealloc];
}
@end
#import
<MediaPlayer/MediaPlayer.h>