vlc | branch: master | Felix Paul Kühne <[email protected]> | Mon Feb 4 21:54:27 2019 +0100| [0be2cd9994ec148a03e157f8ccf56bd6d3c560a1] | committer: Felix Paul Kühne
macosx/player controller: expose teletext and spu options and add playback convinience methods > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0be2cd9994ec148a03e157f8ccf56bd6d3c560a1 --- modules/gui/macosx/playlist/VLCPlayerController.h | 126 +++++++++++++ modules/gui/macosx/playlist/VLCPlayerController.m | 207 +++++++++++++++++++++- 2 files changed, 329 insertions(+), 4 deletions(-) diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h index 2e55196875..a5d2415fce 100644 --- a/modules/gui/macosx/playlist/VLCPlayerController.h +++ b/modules/gui/macosx/playlist/VLCPlayerController.h @@ -79,6 +79,30 @@ extern NSString *VLCPlayerTimeAndPositionChanged; extern NSString *VLCPlayerLengthChanged; /** + * Listen to VLCPlayerTeletextMenuAvailable to be notified if a teletext menu becomes (un-)available + * @note the affected player object will be the object of the notification + */ +extern NSString *VLCPlayerTeletextMenuAvailable; + +/** + * Listen to VLCPlayerTeletextEnabled to be notified if teletext becomes enabled or disabled + * @note the affected player object will be the object of the notification + */ +extern NSString *VLCPlayerTeletextEnabled; + +/** + * Listen to VLCPlayerTeletextPageChanged to be notified if the teletext page changes + * @note the affected player object will be the object of the notification + */ +extern NSString *VLCPlayerTeletextPageChanged; + +/** + * Listen to VLCPlayerTeletextTransparencyChanged to be notified if the teletext transparency changes + * @note the affected player object will be the object of the notification + */ +extern NSString *VLCPlayerTeletextTransparencyChanged; + +/** * Listen to VLCPlayerAudioDelayChanged to be notified if the audio delay of the current media changes * @note the affected player object will be the object of the notification */ @@ -295,6 +319,46 @@ extern NSString *VLCPlayerMuteChanged; - (void)setPositionPrecise:(float)position; /** + * helper function to jump forward with the extra short interval (user configurable in preferences) + */ +- (void)jumpForwardExtraShort; + +/** + * helper function to jump backward with the extra short interval (user configurable in preferences) + */ +- (void)jumpBackwardExtraShort; + +/** + * helper function to jump forward with the short interval (user configurable in preferences) + */ +- (void)jumpForwardShort; + +/** + * helper function to jump backward with the extra short interval (user configurable in preferences) + */ +- (void)jumpBackwardShort; + +/** + * helper function to jump forward with the medium interval (user configurable in preferences) + */ +- (void)jumpForwardMedium; + +/** + * helper function to jump backward with the medium interval (user configurable in preferences) + */ +- (void)jumpBackwardMedium; + +/** + * helper function to jump forward with the long interval (user configurable in preferences) + */ +- (void)jumpForwardLong; + +/** + * helper function to jump forward with the long interval (user configurable in preferences) + */ +- (void)jumpBackwardLong; + +/** * the length of the currently playing media in ticks * @return a valid time or VLC_TICK_INVALID (if no media is set, the media * doesn't have any length, if playback is not yet started or in case of error) @@ -304,6 +368,37 @@ extern NSString *VLCPlayerMuteChanged; @property (readonly) vlc_tick_t length; /** + * exposes whether a teletext menu is available or not + * @note listen to VLCPlayerTeletextMenuAvailable to be notified about changes to this property + */ +@property (readonly) BOOL teletextMenuAvailable; + +/** + * enable/disable teletext display + * @note listen to VLCPlayerTeletextEnabled to be notified about changes to this property + */ +@property (readwrite, nonatomic) BOOL teletextEnabled; + +/** + * set/get the currently displayed (or looked for) teletext page + * + * @note Page keys can be the following: @ref VLC_PLAYER_TELETEXT_KEY_RED, + * @ref VLC_PLAYER_TELETEXT_KEY_GREEN, @ref VLC_PLAYER_TELETEXT_KEY_YELLOW, + * @ref VLC_PLAYER_TELETEXT_KEY_BLUE or @ref VLC_PLAYER_TELETEXT_KEY_INDEX. + * + * @param page a page in the range 0 to 888 or a valid key + * @note listen to VLCPlayerTeletextPageChanged to be notified about changes to this property + */ +@property (readwrite, nonatomic) unsigned int teletextPage; + +/** + * is the teletext background transparent or not? + * @return a BOOL value indicating the current state + * @note listen to VLCPlayerTeletextTransparencyChanged to be notified about changes to this property + */ +@property (readwrite, nonatomic) BOOL teletextTransparent; + +/** * the audio delay for the current media * @warning this property expects you to provide an absolute delay time * @return the audio delay in vlc ticks @@ -320,6 +415,12 @@ extern NSString *VLCPlayerMuteChanged; @property (readwrite, nonatomic) vlc_tick_t subtitlesDelay; /** + * a scale factor for text based subtitles, range 10 - 500, default 100 + * @warning this does not have any effect on bitmapped subtitles + */ +@property (readwrite, nonatomic) unsigned int subtitleTextScalingFactor; + +/** * enable recording of the current media or check if it is being done * @note listen to VLCPlayerRecordingChanged to be notified about changes to this property */ @@ -334,11 +435,21 @@ extern NSString *VLCPlayerMuteChanged; @property (readwrite, nonatomic) BOOL fullscreen; /** + * helper function to inverse the current fullscreen state + */ +- (void)toggleFullscreen; + +/** * indicates whether video is displaed in wallpaper mode or shall to * @note listen to VLCPlayerWallpaperModeChanged to be notified about changes to this property */ @property (readwrite, nonatomic) BOOL wallpaperMode; +/** + * Take a snapshot of all vouts + */ +- (void)takeSnapshot; + #pragma mark - audio output properties /** @@ -349,11 +460,26 @@ extern NSString *VLCPlayerMuteChanged; @property (readwrite, nonatomic) float volume; /** + * helper function to increase volume by 5% + */ +- (void)incrementVolume; + +/** + * helper function to decrease volume by 5% + */ +- (void)decrementVolume; + +/** * reveals or sets whether audio output is set to mute or not * @note listen to VLCPlayerMuteChanged to be notified about changes to this property */ @property (readwrite, nonatomic) BOOL mute; +/** + * helper function to inverse the current mute state + */ +- (void)toggleMute; + @end NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m index d3f7ad5fef..76bde08df2 100644 --- a/modules/gui/macosx/playlist/VLCPlayerController.m +++ b/modules/gui/macosx/playlist/VLCPlayerController.m @@ -21,6 +21,7 @@ *****************************************************************************/ #import "VLCPlayerController.h" +#import "main/VLCMain.h" NSString *VLCPlayerCurrentMediaItem = @"VLCPlayerCurrentMediaItem"; NSString *VLCPlayerCurrentMediaItemChanged = @"VLCPlayerCurrentMediaItemChanged"; @@ -32,8 +33,13 @@ NSString *VLCPlayerRateChanged = @"VLCPlayerRateChanged"; NSString *VLCPlayerCapabilitiesChanged = @"VLCPlayerCapabilitiesChanged"; NSString *VLCPlayerTimeAndPositionChanged = @"VLCPlayerTimeAndPositionChanged"; NSString *VLCPlayerLengthChanged = @"VLCPlayerLengthChanged"; +NSString *VLCPlayerTeletextMenuAvailable = @"VLCPlayerTeletextMenuAvailable"; +NSString *VLCPlayerTeletextEnabled = @"VLCPlayerTeletextEnabled"; +NSString *VLCPlayerTeletextPageChanged = @"VLCPlayerTeletextPageChanged"; +NSString *VLCPlayerTeletextTransparencyChanged = @"VLCPlayerTeletextTransparencyChanged"; NSString *VLCPlayerAudioDelayChanged = @"VLCPlayerAudioDelayChanged"; NSString *VLCPlayerSubtitlesDelayChanged = @"VLCPlayerSubtitlesDelayChanged"; +NSString *VLCPlayerSubtitleTextScalingFactorChanged = @"VLCPlayerSubtitleTextScalingFactorChanged"; NSString *VLCPlayerRecordingChanged = @"VLCPlayerRecordingChanged"; NSString *VLCPlayerFullscreenChanged = @"VLCPlayerFullscreenChanged"; NSString *VLCPlayerWallpaperModeChanged = @"VLCPlayerWallpaperModeChanged"; @@ -57,8 +63,13 @@ NSString *VLCPlayerMuteChanged = @"VLCPlayerMuteChanged"; - (void)capabilitiesChanged:(int)newCapabilities; - (void)position:(float)position andTimeChanged:(vlc_tick_t)time; - (void)lengthChanged:(vlc_tick_t)length; +- (void)teletextAvailibilityChanged:(BOOL)hasTeletextMenu; +- (void)teletextEnabledChanged:(BOOL)teletextOn; +- (void)teletextPageChanged:(unsigned int)page; +- (void)teletextTransparencyChanged:(BOOL)isTransparent; - (void)audioDelayChanged:(vlc_tick_t)audioDelay; - (void)subtitlesDelayChanged:(vlc_tick_t)subtitlesDelay; +- (void)subtitleTextScaleChanged:(unsigned int)subtitleTextScalingFactor; - (void)recordingChanged:(BOOL)recording; - (void)stopActionChanged:(enum vlc_player_media_stopped_action)stoppedAction; @@ -145,6 +156,42 @@ static void cb_player_length_changed(vlc_player_t *p_player, vlc_tick_t newLengt }); } +static void cb_player_teletext_menu_availability_changed(vlc_player_t *p_player, bool hasTeletextMenu, void *p_data) +{ + VLC_UNUSED(p_player); + dispatch_async(dispatch_get_main_queue(), ^{ + VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data; + [playerController teletextAvailibilityChanged:hasTeletextMenu]; + }); +} + +static void cb_player_teletext_enabled_changed(vlc_player_t *p_player, bool teletextEnabled, void *p_data) +{ + VLC_UNUSED(p_player); + dispatch_async(dispatch_get_main_queue(), ^{ + VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data; + [playerController teletextEnabledChanged:teletextEnabled]; + }); +} + +static void cb_player_teletext_page_changed(vlc_player_t *p_player, unsigned page, void *p_data) +{ + VLC_UNUSED(p_player); + dispatch_async(dispatch_get_main_queue(), ^{ + VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data; + [playerController teletextPageChanged:page]; + }); +} + +static void cb_player_teletext_transparency_changed(vlc_player_t *p_player, bool isTransparent, void *p_data) +{ + VLC_UNUSED(p_player); + dispatch_async(dispatch_get_main_queue(), ^{ + VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data; + [playerController teletextTransparencyChanged:isTransparent]; + }); +} + static void cb_player_audio_delay_changed(vlc_player_t *p_player, vlc_tick_t newDelay, void *p_data) { VLC_UNUSED(p_player); @@ -195,10 +242,10 @@ static const struct vlc_player_cbs player_callbacks = { NULL, //cb_player_titles_changed, NULL, //cb_player_title_selection_changed, NULL, //cb_player_chapter_selection_changed, - NULL, //cb_player_teletext_menu_changed, - NULL, //cb_player_teletext_enabled_changed, - NULL, //cb_player_teletext_page_changed, - NULL, //cb_player_teletext_transparency_changed, + cb_player_teletext_menu_availability_changed, + cb_player_teletext_enabled_changed, + cb_player_teletext_page_changed, + cb_player_teletext_transparency_changed, cb_player_audio_delay_changed, cb_player_subtitle_delay_changed, NULL, //cb_player_associated_subs_fps_changed, @@ -497,6 +544,63 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { vlc_player_Unlock(_p_player); } +- (void)jumpWithValue:(char *)p_userDefinedJumpSize forward:(BOOL)shallJumpForward +{ + int64_t interval = var_InheritInteger(getIntf(), p_userDefinedJumpSize); + if (interval > 0) { + vlc_tick_t jumptime = vlc_tick_from_sec( interval ); + if (!shallJumpForward) + jumptime = jumptime * -1; + + /* No fask seek for jumps. Indeed, jumps can seek to the current position + * if not precise enough or if the jump value is too small. */ + vlc_player_SeekByTime(_p_player, + jumptime, + VLC_PLAYER_SEEK_PRECISE, + VLC_PLAYER_WHENCE_RELATIVE); + } +} + +- (void)jumpForwardExtraShort +{ + [self jumpWithValue:"extrashort-jump-size" forward:YES]; +} + +- (void)jumpBackwardExtraShort +{ + [self jumpWithValue:"extrashort-jump-size" forward:NO]; +} + +- (void)jumpForwardShort +{ + [self jumpWithValue:"short-jump-size" forward:YES]; +} + +- (void)jumpBackwardShort +{ + [self jumpWithValue:"short-jump-size" forward:NO]; +} + +- (void)jumpForwardMedium +{ + [self jumpWithValue:"medium-jump-size" forward:YES]; +} + +- (void)jumpBackwardMedium +{ + [self jumpWithValue:"medium-jump-size" forward:NO]; +} + +- (void)jumpForwardLong +{ + [self jumpWithValue:"long-jump-size" forward:YES]; +} + +- (void)jumpBackwardLong +{ + [self jumpWithValue:"long-jump-size" forward:NO]; +} + - (void)lengthChanged:(vlc_tick_t)length { _length = length; @@ -504,6 +608,55 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { object:self]; } +- (void)teletextAvailibilityChanged:(BOOL)hasTeletextMenu +{ + _teletextMenuAvailable = hasTeletextMenu; + [_defaultNotificationCenter postNotificationName:VLCPlayerTeletextTransparencyChanged + object:self]; +} + +- (void)teletextEnabledChanged:(BOOL)teletextOn +{ + _teletextEnabled = teletextOn; + [_defaultNotificationCenter postNotificationName:VLCPlayerTeletextEnabled + object:self]; +} + +- (void)setTeletextEnabled:(BOOL)teletextEnabled +{ + vlc_player_Lock(_p_player); + vlc_player_SetTeletextEnabled(_p_player, teletextEnabled); + vlc_player_Unlock(_p_player); +} + +- (void)teletextPageChanged:(unsigned int)page +{ + _teletextPage = page; + [_defaultNotificationCenter postNotificationName:VLCPlayerTeletextPageChanged + object:self]; +} + +- (void)setTeletextPage:(unsigned int)teletextPage +{ + vlc_player_Lock(_p_player); + vlc_player_SelectTeletextPage(_p_player, teletextPage); + vlc_player_Unlock(_p_player); +} + +- (void)teletextTransparencyChanged:(BOOL)isTransparent +{ + _teletextTransparent = isTransparent; + [_defaultNotificationCenter postNotificationName:VLCPlayerTeletextTransparencyChanged + object:self]; +} + +- (void)setTeletextTransparent:(BOOL)teletextTransparent +{ + vlc_player_Lock(_p_player); + vlc_player_SetTeletextTransparency(_p_player, teletextTransparent); + vlc_player_Unlock(_p_player); +} + - (void)audioDelayChanged:(vlc_tick_t)audioDelay { _audioDelay = audioDelay; @@ -532,6 +685,27 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { vlc_player_Unlock(_p_player); } +- (unsigned int)subtitleTextScalingFactor +{ + unsigned int ret = 100; + vlc_player_Lock(_p_player); + ret = vlc_player_GetSubtitleTextScale(_p_player); + vlc_player_Unlock(_p_player); + return ret; +} + +- (void)setSubtitleTextScalingFactor:(unsigned int)subtitleTextScalingFactor +{ + if (subtitleTextScalingFactor < 10) + subtitleTextScalingFactor = 10; + if (subtitleTextScalingFactor > 500) + subtitleTextScalingFactor = 500; + + vlc_player_Lock(_p_player); + vlc_player_SetSubtitleTextScale(_p_player, subtitleTextScalingFactor); + vlc_player_Unlock(_p_player); +} + - (void)recordingChanged:(BOOL)recording { _enableRecording = recording; @@ -560,6 +734,11 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { vlc_player_vout_SetFullscreen(_p_player, fullscreen); } +- (void)toggleFullscreen +{ + vlc_player_vout_SetFullscreen(_p_player, !_fullscreen); +} + - (void)wallpaperModeChanged:(BOOL)wallpaperModeValue { _wallpaperMode = wallpaperModeValue; @@ -572,6 +751,11 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { vlc_player_vout_SetWallpaperModeEnabled(_p_player, wallpaperMode); } +- (void)takeSnapshot +{ + vlc_player_vout_Snapshot(_p_player); +} + #pragma mark - audio specific delegation - (void)volumeChanged:(float)volume @@ -586,6 +770,16 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { vlc_player_aout_SetVolume(_p_player, volume); } +- (void)incrementVolume +{ + vlc_player_aout_SetVolume(_p_player, _volume + 0.05); +} + +- (void)decrementVolume +{ + vlc_player_aout_SetVolume(_p_player, _volume - 0.05); +} + - (void)muteChanged:(BOOL)mute { _mute = mute; @@ -598,4 +792,9 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = { vlc_player_aout_Mute(_p_player, mute); } +- (void)toggleMute +{ + vlc_player_aout_Mute(_p_player, !_mute); +} + @end _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
