Please add currentPlaybackTime to Titanium.Media.VideoPlayer

You must Login before you can answer or comment on any questions.

Would be really useful to have this. Its been in the iOS SDK since 3.2: http://stackoverflow.com/questions/3163388

— asked 4 years ago by James Low
0 Comments

10 Answers

OOOh currentPlaybacktime seems to be already added in 1.6.2 ! BUT, it is not possible to set the value, I add function in TiMediaPlayerProxy.m this way:

-(void)setcurrentPlaybackTime:(id)value
{
    [self player].currentPlaybackTime=[TiUtils doubleValue:value];
 
}
And in your app.js, just write this to seek to the time you want:
VideoPlayer.setcurrentPlaybacktime(15);     //For 15 seconds

— answered 3 years ago by Yoann WYFFELS
answer permalink
11 Comments
  • In TiMediaPlayerProxy.m ? You mean TiMediaVideoPlayerProxy.m ? I tried to add it to TiMediaVideoPlayerProxy.m in the build folder, but nothing happens when the function is called

    — commented 3 years ago by Maxime Layat

  • Yes, you're right, I mean TiMediaVideoPlayerProxy.m :)

    You need to rebuild your application (because .m and .h are already linked at the first run).

    To do it, simply delete the "build" folder in "Your Project Directory\build\build" (the last "build" directory is the one to delete), and launch your application in titanium dev or studio.

    you may also apply the TiMediaVideoPlayerProxy.m modifications directly in the titanium sdk sources : futur projects will directly have the improved version ;) /Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/Classes (and change 1.6.2 with the sdk version you have)

    — commented 3 years ago by Yoann WYFFELS

  • Thank you for this tip. Could you explain how to make this change in the source. Do I update /Library/Application Support/Titanium/mobilesdk/osx/17.1/iphone/Classes/TiMediaVideoPlayerProxy.m with your set method and then re-compile my app? Or do I need to update my local copy of the source and re-run scons? When I try to build titanium from the source on my MacBook it looks like only the android is built. I'm new to this world - sorry if these questions are lame. I really need to be able to seek without first stopping the video. Thank you!

    — commented 3 years ago by Chris Caruso

  • Show 8 more comments

I've managed to use this by adding the following to TiMediaVideoPlayerProxy.m but it would be great if it was in the main code.

-(NSNumber*)currentPlaybackTime
{
    if (movie != nil) {
        return NUMDOUBLE([[self player] currentPlaybackTime]);
    }
    else {
        RETURN_FROM_LOAD_PROPERTIES(@"initialPlaybackTime", NUMINT(0));
    }
}

Yay! setCurrentPlaybackTime is now supported in 3.1.1.GA!! Thank you Titanium devs. :) No more need for hacks. I am happy.

Dears

for backward videoPlayer.setCurrentPlaybackTime($.videoPlayer.getCurrentPlaybackTime()-6000); for forward videoPlayer.setCurrentPlaybackTime($.videoPlayer.getCurrentPlaybackTime()-6000);

please put ur time in milliseconds

Totally agree with you, this is a little implementation for great services...Go Go Titanium developper team ! :)

hi,

when I use setcurrentPlaybackTime(15) it gives <null> value..why?

Does anyone have a solution for the above using sdk 2.0.1 as the above no longer seems to work?

Thanks

Is there anyone who can tell how to override this class. I couldn't find the location "/Library/Application Support/Titanium/mobilesdk/osx/17.1/iphone/Classes/TiMediaVideoPlayerProxy.m" I just can find it in my project's build destination and it's cleared whenever I build the project.

Here is an updated setcurrentPlaybackTime obj-c function for TiMediaVideoPlayerProxy.m. This works with sdk 2.0.1.GA.

-(void)setcurrentPlaybackTime:(id)time
{
  ENSURE_UI_THREAD_1_ARG(time);
  if (movie != nil) {
    NSTimeInterval ourTime = [[time objectAtIndex:0] doubleValue];
    if (ourTime > 0) {
      [movie setCurrentPlaybackTime: ourTime];
    }
  }
}

Your Answer

Think you can help? Login to answer this question!