WKInterfaceObject+VLCProgress.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*****************************************************************************
  2. * WKInterfaceObject+VLCProgress.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Author: Tobias Conradi <videolan # tobias-conradi.de>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "WKInterfaceObject+VLCProgress.h"
  13. @implementation WKInterfaceObject (VLCProgress)
  14. -(void)vlc_setProgress:(float)progress
  15. {
  16. float progressWidth = ceil(progress * CGRectGetWidth([WKInterfaceDevice currentDevice].screenBounds));
  17. self.width = progressWidth;
  18. }
  19. - (void)vlc_setProgress:(float)progress hideForNoProgress:(BOOL)hideForNoProgress
  20. {
  21. [self vlc_setProgress:progress];
  22. BOOL noProgress = progress == 0.0;
  23. self.hidden = noProgress && hideForNoProgress;
  24. }
  25. - (void)vlc_setProgressFromPlaybackTime:(float)playbackTime duration:(float)duration hideForNoProgess:(BOOL)hideForNoProgress
  26. {
  27. float playbackProgress = 0.0;
  28. if (playbackTime > 0.0 && duration > 0.0) {
  29. playbackProgress = playbackTime / duration;
  30. }
  31. [self vlc_setProgress:playbackProgress hideForNoProgress:hideForNoProgress];
  32. }
  33. @end