Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Using MPMoviePlayerController undocumented methods...

smithdale87smithdale87 Posts: 4,431iPhone Dev SDK Supporter @ @ @ @ @
edited July 2009 in iPhone SDK Development
First off, I know this is wrong, but since this app is for personal use, I don't think it's gonna hurt anyone if I use a few undocumented calls.

Here's what I'm trying to do:

I have an overlay view on top of a MPMoviePlayerController .. nothing hard about that.

Now, when I click one of the buttons, I want to get the current time of the video that's being played. For this, there's a "currentTime" method in the mpmovieplayercontroller class.

However, when compiling, I get the ole warning "MPMoviePlayerController" may not respond to '-currentTime'. This method is assumed to return 'id' and accept '...' as arguments.


So my problem is that I need to get a 'double' value from the currentTime rather than an object. I've tried casting, but this doesnt work either.

Any suggestions?

Just to clarify, the mpmovieplayercontroller has a method with signature:
-(double)currentTime;

But the compiler assumes it looks like this:
-(id)currentTime;
Post edited by smithdale87 on

Replies

  • smithdale87smithdale87 Posts: 4,431iPhone Dev SDK Supporter @ @ @ @ @
    edited June 2009
  • mnemonic_fxmnemonic_fx Posts: 419Registered Users
    edited June 2009
    What is the exact class name of the object ?
    NSLog(@"%@", [[self currentTime] description]);
    
    
    <a href="http://jessearmand.com" target="_blank"> Visit Me </a><br />
    <br />
    <i>Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That'
  • smithdale87smithdale87 Posts: 4,431iPhone Dev SDK Supporter @ @ @ @ @
    edited June 2009
    Not near my mac right now, but thanks for the idea. I'll let you know as soon as I get home from my day job lol.
  • smithdale87smithdale87 Posts: 4,431iPhone Dev SDK Supporter @ @ @ @ @
    edited June 2009
    Here's my stuff:
    MPMoviePlayerController* video = ... 
    

    Now, as you suggested:
    NSLog(@"%@", [[video currentTime] description]);
    
    This throws an EXC_BAD_ACCESS, my guess is because the method actually returns a primitive type, rather than an NSObject.

    If I just do
    NSLog(@"%@", [video currentTime]);
    
    I also get an EXC_BAD_ACCESS

    Now, if I do
    NSLog(@"%.2f", [video currentTime]);
    
    I get "0.00" printed out.

    Now the question is, why does it print 0.00 rather than the actual currentTime?
  • mnemonic_fxmnemonic_fx Posts: 419Registered Users
    edited June 2009
    It might mean that, the currentTime doesn't return anything useful.

    What if you passed it as integer using %d ?
    <a href="http://jessearmand.com" target="_blank"> Visit Me </a><br />
    <br />
    <i>Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That'
  • smithdale87smithdale87 Posts: 4,431iPhone Dev SDK Supporter @ @ @ @ @
    edited June 2009
    That's what I feared. I havent tried using %d yet. I'll do so when I get near my mac again.

    On the other hand, I only need the currentTime value to figure out how long the video has been playing. I've tried a workaround by just initializing an NSDate object when I call [video play]. Then, when the video stops, I can call the timeIntervalSinceNow method from NSDate to figure out the elapsed time since the movie started.

    The only issue now is that if the user pressed the "pause" button, I have no way of getting notified to adjust the elapsed time. My solution would be to overlay an invisible button on top of the 'pause' button on the movie player so that when the user thinks he/she is hittin pause, they are actually hitting the invis button I've overlayed. This will allow me to capture that event, adjust the elapsed time, and then pass the touch on to the movie player so it can actually pause the movie.

    The problem I'm facing here is that I can't figure out how to pass the touch on to be handled by the movie player controller.

    Any ideas?
  • mnemonic_fxmnemonic_fx Posts: 419Registered Users
    edited June 2009
    Have you take a look at HeadsUpUI ?

    You can hide the controls by using MPMovieControlModeHidden, and then handle all of the play and stop of MPMoviePlayerController by using that custom button.
    <a href="http://jessearmand.com" target="_blank"> Visit Me </a><br />
    <br />
    <i>Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That'
  • DmitryDmitry Posts: 11Registered Users
    edited July 2009
    That's what I feared. I havent tried using %d yet. I'll do so when I get near my mac again.

    On the other hand, I only need the currentTime value to figure out how long the video has been playing. I've tried a workaround by just initializing an NSDate object when I call [video play]. Then, when the video stops, I can call the timeIntervalSinceNow method from NSDate to figure out the elapsed time since the movie started.

    The only issue now is that if the user pressed the "pause" button, I have no way of getting notified to adjust the elapsed time. My solution would be to overlay an invisible button on top of the 'pause' button on the movie player so that when the user thinks he/she is hittin pause, they are actually hitting the invis button I've overlayed. This will allow me to capture that event, adjust the elapsed time, and then pass the touch on to the movie player so it can actually pause the movie.

    The problem I'm facing here is that I can't figure out how to pass the touch on to be handled by the movie player controller.

    Any ideas?

    Hi Smithdale,

    It's good idea, but if you have slow internet connection, your movie will stops sometimes. In this case you need to catch this event and do the same thing that you want to do with pause buttons. I don't thing that this event exists at all.

    Actually, I have the same problem with currentTime functions. I don't know solution yet, but if it helps I tell you that I try to convert the value returned from currentTime functions to each value from this list String Programming Guide for Cocoa: String Format Specifiers , (with stringWithFormat) and each time it returns a garbage
Sign In or Register to comment.