Browse Source

macosx/coreinteraction: reimplement play/pause toggle

pull/85/head
Felix Paul Kühne 7 years ago
parent
commit
9764ef67a6
  1. 15
      modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
  2. 5
      modules/gui/macosx/playlist/VLCPlayerController.h
  3. 12
      modules/gui/macosx/playlist/VLCPlayerController.m

15
modules/gui/macosx/coreinteraction/VLCCoreInteraction.m

@ -31,6 +31,7 @@
#import "main/VLCMain.h"
#import "coreinteraction/VLCClickerManager.h"
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlayerController.h"
#import "playlist/VLCPlaylistModel.h"
#import "windows/VLCOpenWindowController.h"
@ -117,18 +118,18 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
- (void)playOrPause
{
input_thread_t *p_input = pl_CurrentInput(getIntf());
playlist_t *p_playlist = pl_Get(getIntf());
VLCMain *mainInstance = [VLCMain sharedInstance];
VLCPlaylistController *playlistController = mainInstance.playlistController;
input_item_t *p_input_item = playlistController.currentlyPlayingInputItem;
if (p_input) {
playlist_TogglePause(p_playlist);
vlc_object_release(p_input);
if (p_input_item) {
[playlistController.playerController togglePlayPause];
input_item_Release(p_input_item);
} else {
VLCMain *mainInstance = [VLCMain sharedInstance];
if (mainInstance.playlistController.playlistModel.numberOfPlaylistItems == 0)
[[mainInstance open] openFileGeneric];
else
[mainInstance.playlistController startPlaylist];
[playlistController startPlaylist];
}
}

5
modules/gui/macosx/playlist/VLCPlayerController.h

@ -171,6 +171,11 @@ extern NSString *VLCPlayerMuteChanged;
*/
- (void)resume;
/**
* Convinience method to either start or pause playback
*/
- (void)togglePlayPause;
/**
* Stop the current playback
*/

12
modules/gui/macosx/playlist/VLCPlayerController.m

@ -387,6 +387,18 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
vlc_player_Unlock(_p_player);
}
- (void)togglePlayPause
{
vlc_player_Lock(_p_player);
if (_playerState == VLC_PLAYER_STATE_PLAYING) {
vlc_player_Pause(_p_player);
} else if (_playerState == VLC_PLAYER_STATE_PAUSED) {
vlc_player_Resume(_p_player);
} else
vlc_player_Start(_p_player);
vlc_player_Unlock(_p_player);
}
- (void)stop
{
vlc_player_Lock(_p_player);

Loading…
Cancel
Save