Please add currentPlaybackTime to Titanium.Media.VideoPlayer

Would be really useful to have this. Its been in the iOS SDK since 3.2:

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:

        [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 4 years ago by Yoann WYFFELS
    • 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 4 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 4 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 4 years ago by Chris Caruso
    • It is already explain how to make change to SDK sources in my old thread. Two ways to do it:

      if you want to make change in the main SDK (for all your futur projects), simply modify the TiMediaVideoPlayerProxy.m in the /Library/Application Support/Titanium/mobilesdk/osx/1.7.1/iphone/Classes

      Or if you want to make change only for your project, modify the TiMediaVideoPlayerProxy.m in the build/iphone/Classes in your project directory

      For both solutions, you need to do a full rebuild by deleting "Your Project Directory\build\build" directory

      — commented 4 years ago by Yoann WYFFELS
    • Thank you for your reply. I finally found my problem. The post (which was very, very helpful) defines the setter as 'setcurrentPlaybackTime' and the example uses 'setcurrentPlaybacktime' - small 't' ! I copied and pasted directly from the post - I must be getting old. Thank you again.

      — commented 4 years ago by Chris Caruso
    • Ohhhh this is glorious!!! I've been trying to accomplish this for so long. And yes, please get this in the API so we don't have to hack! Either way, I'm a happy camper right now. :)

      — commented 4 years ago by Nick Robillard
    • I'll take a look at getting a pull request in for this.

      — commented 4 years ago by Kevin Whinnery
    • Hi, it looks like this is for iOS, how can I enable something like this for Android also?

      — commented 4 years ago by Ki Hwan Song
    • Well this has been working nicely for me pre However, now that I've upgraded to, setcurrentPlaybacktime always sets the playback to 0. :( Anyone know what changed? I'm seeing that other playback values and durations are now in milliseconds but I don't think that should affect this.

      — commented 4 years ago by Nick Robillard
    • hi,

      I m getting error win.setcurrentPlaybackTime[undefined] is not function

      — commented 4 years ago by Amol Jadhav
    • hi again,

      now I m not getting error but still its not working(doing nothing)..

      — commented 4 years ago by Amol Jadhav
  • 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.

        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.

    — answered 2 years ago by Nick Robillard
    • Note: Just be sure to pass a millisecond value - not seconds.

      — commented 2 years ago by Nick Robillard
    • Hello Nick,

      Where do you find an example of this?


      — commented 2 years ago by Nicolai Villadsen
  • 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?


  • 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.

      if (movie != nil) {
        NSTimeInterval ourTime = [[time objectAtIndex:0] doubleValue];
        if (ourTime > 0) {
          [movie setCurrentPlaybackTime: ourTime];