Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7777547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:10:12+00:00 2026-06-01T18:10:12+00:00

i am creating one iPad application in that i want to open media player

  • 0

i am creating one iPad application in that i want to open media player to play video. For this i create one button in ViewDidLoad() method. Bellow is my code.

- (void)viewDidLoad
{
    [super viewDidLoad]
    self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"1.png"]] autorelease];

    m_btn2000 = [[UIButton buttonWithType:UIButtonTypeCustom] autorelease];
    m_btn2000.frame = CGRectMake(180, 330, 130, 200);
   [m_btn2000 setImage:[UIImage imageNamed:@"2.png"] forState:UIControlStateNormal];
    m_btn2000.clipsToBounds = YES;
   [m_btn2000 addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
   [self.view addSubview:m_btn2000];
}

Bellow is my button clicked method code:

- (void)btnClicked:(id)sender
{
    NSString *filePath1 = [[NSBundle mainBundle] pathForResource:@"test_video" ofType:@"m4v"];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath1];
    m_moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    m_moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
   [m_moviePlayer.view setFrame:CGRectMake(0, 0, 1026, 748)];
   [self.view addSubview:m_moviePlayer.view];
   [m_moviePlayer play];
}

when i m going to click on button it gives me EXC_BAD_ACCESS error.
But i notice one thing that when i put above whole code which in button clicked method putting in ViewDidLoad() method it play a video in player proper way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:10:13+00:00Added an answer on June 1, 2026 at 6:10 pm

    The reason is : you are creating a button with + (factory method) and you are sending autorelease message.

    you need to change this line from:
    m_btn2000 = [[UIButton buttonWithType:UIButtonTypeCustom] autorelease];

    to

      m_btn2000 = [UIButton buttonWithType:UIButtonTypeCustom];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an iPad application which needs a UIPopoverController like this one (I mean,
I am creating one web application in GRAILS framework.In that I want to implement
I've creating one ASP web application, in that application one form have to update
I am creating one application in which i am using jsp/servlet.. I want to
How would one go about creating an ipad app that has a similar view
I am creating an iPad as in the link . In this one I
When creating one Intent so that MyActivity reacts to a User pressing the Home-button
I am creating one application in iOs 5 using story board and in that
I'm creating ipad application. It has just 2 views. One view has few buttons.
For one of my last school projects, I am creating an iPad/iPhone application. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.