views:

19

answers:

0
- (void) Scrollviews
{  
  self.scrollView = [[[UIScrollView alloc] initWithFrame:CGRectMake(32, 110, 3000.0, 237.0)] autorelease];
    self.scrollView.contentSize = CGSizeMake(NPAGES * 320.0f, scrollView.frame.size.height);
    self.scrollView.pagingEnabled = YES;
    self.scrollView.delegate = self;
    [self.scrollView setUserInteractionEnabled:YES];

    pageControl.numberOfPages = NPAGES;
    pageControl.currentPage = 0;
    [pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];

    leftimage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 165, 37, 37)];
    leftimage.backgroundColor = [UIColor blackColor];
    leftimage.image = [UIImage imageNamed:@"arrow_left.png"];
    [self.view addSubview:leftimage];

    rightimage = [[UIImageView alloc] initWithFrame:CGRectMake(290, 165, 37, 37)];
    rightimage.backgroundColor = [UIColor blackColor];
    rightimage.image = [UIImage imageNamed:@"arrow_right.png"];
    [self.view addSubview:rightimage];

    NSArray *videoArr = [preferences Videos:@"HealthHistoryDemoLisa"];
    NSString *imageStr = [videoArr objectAtIndex:1];
    bottomLabelstr = [videoArr objectAtIndex:2];
    videoURL = [videoArr objectAtIndex:0];

    class2Arr = [[NSMutableArray alloc] init];
    [class2Arr addObject:bottomLabelstr];
    [class2Arr addObject:@"Healthy Cooking"];
    [class2Arr addObject:@"HealthySlide 1"];
    [class2Arr addObject:@"HealthySlide 2"];
    [class2Arr addObject:@"HealthySlide 3"];
    [class2Arr addObject:@"HealthySlide 4"];
    [class2Arr addObject:@"Introduction to Health_Histories"];
    [class2Arr addObject:@"2b"];
    [class2Arr addObject:@"2c"];
    [class2Arr addObject:@"2d"];

    UIImageView *videoImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageStr]];
    videoImg.frame = CGRectMake(0.0, 6.0, 251.0, BASEHEIGHT);  
    [self.scrollView addSubview:videoImg];
    [videoImg release];

    UILabel *bottomLbl = [[UILabel alloc] initWithFrame:CGRectMake(30.0, 210.0, 200.0, 60)];
    bottomLbl.textColor = [UIColor whiteColor];
    bottomLbl.backgroundColor = [UIColor clearColor];
    bottomLbl.text = bottomLabelstr;
    bottomLbl.numberOfLines = 2;
    [self.scrollView addSubview:bottomLbl];

    imagePlayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    imagePlayBtn.frame = CGRectMake(120.0, 70, 26, 26);
    [imagePlayBtn setBackgroundImage:[UIImage imageNamed:@"arrow_page_popup.png"] forState:UIControlStateNormal];
    [imagePlayBtn addTarget:self action:@selector(PlayMovie:) forControlEvents:UIControlEventTouchUpInside];

    [self.scrollView addSubview:imagePlayBtn];

    UIImageView *playerImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"player_bg.png"]];
    playerImage.frame = CGRectMake(320.0, 40.0, 251.0, 86.0);
    [self.scrollView addSubview:playerImage];
    [playerImage release];


    NSString *urlStr1 = [[NSBundle mainBundle] pathForResource:@"2a. Healthy Cooking" ofType:@"m4a"];
    NSURL *url1 = [NSURL fileURLWithPath:urlStr1];
    moviePlayer1 = [[MPMoviePlayerController alloc] initWithContentURL:url1];
    moviePlayer1.view.frame = CGRectMake(320.0, 6.0, 251.0, 200.0);  
    [moviePlayer1 stop];
    [self.scrollView addSubview:moviePlayer1.view];

    UILabel *healthLabel = [[UILabel alloc]initWithFrame:CGRectMake(334, 130.0, 200.0, 40)];
    healthLabel.textColor = [UIColor whiteColor];
    [healthLabel setBackgroundColor:[UIColor clearColor]];
    healthLabel.text = @"Healthy Cooking";
    healthLabel.textAlignment = UITextAlignmentCenter;
    healthLabel.numberOfLines = 2;
    [self.scrollView addSubview:healthLabel];


    for (int i = 2; i<= 5; i++) {

    NSString *filename = [NSString stringWithFormat:@"HealthySlide%d.png",i];
    UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename]];
    iv.frame = CGRectMake(i*320.0f, 6.0f, 241.0f, BASEHEIGHT);
    [scrollView addSubview:iv];
    [iv release];

    }

    UIImageView *playerImage1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"player_bg.png"]];
    playerImage1.frame = CGRectMake(1920.0, 40.0, 251.0, 86.0);
    [self.scrollView addSubview:playerImage1];
    [playerImage1 release];

    NSString *urlStr2 = [[NSBundle mainBundle] pathForResource:@"2c.__Introduction_to_Health_Histories" ofType:@"m4a"];
    NSURL *url2 = [NSURL fileURLWithPath:urlStr2];
    moviePlayer2 = [[MPMoviePlayerController alloc] initWithContentURL:url2];
    moviePlayer2.view.frame = CGRectMake(1920.0, 6.0, 251.0, 200.0);  
    [moviePlayer2 stop];
    [self.scrollView addSubview:moviePlayer2.view];

    UILabel *healthLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(1934, 130.0, 200.0, 40)];
    healthLabel1.textColor = [UIColor whiteColor];
    [healthLabel1 setBackgroundColor:[UIColor clearColor]];
    healthLabel1.text = @"2c. Introduction to Health_Histories";
    healthLabel1.textAlignment = UITextAlignmentCenter;
    healthLabel1.numberOfLines = 2;
    [self.scrollView addSubview:healthLabel1];

    NSString *filename1 = [NSString stringWithFormat:@"2b.png"];
    UIImageView *iv1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename1]];
    iv1.frame = CGRectMake(2240.0f, 6.0f, 241.0f, BASEHEIGHT);
    [scrollView addSubview:iv1];
    [iv1 release];

    NSString *filename2 = [NSString stringWithFormat:@"2c.png"];
    UIImageView *iv2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename2]];
    iv2.frame = CGRectMake(2560.0f, 6.0f, 241.0f, BASEHEIGHT);
    [scrollView addSubview:iv2];
    [iv2 release];

    NSString *filename3 = [NSString stringWithFormat:@"2d.png"];
    UIImageView *iv3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename3]];
    iv3.frame = CGRectMake(2880.0f, 6.0f, 241.0f, BASEHEIGHT);
    [scrollView addSubview:iv3];
    [iv3 release];

    /*NSString *filename4 = [NSString stringWithFormat:@"2e.png"];
    UIImageView *iv4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename4]];
    iv3.frame = CGRectMake(3200.0f, 6.0f, 241.0f, BASEHEIGHT);
    [scrollView addSubview:iv4];
    [iv4 release];*/

    [self.view addSubview:scrollView];

    self.popup = @"DOWN";
}

My Movieplayer2 is showing perfectly fi9 and when I disable it so my MoviePlayer1 start displaying. Why is it loosing it value as both are different object of MoviePlayer Class and are at different location.