Commit f61b98f5 authored by Robert Gordon's avatar Robert Gordon Committed by Carola Nitz

MediaPlaybackControlToolbar: Handle playback buttons functionality through delegate

Handled functionality for the control through VLCMovieViewControlViewController adopting delegate functionality"
parent 1635d232
/*****************************************************************************
* MediaPlaybackControlToolbar.swift
*
* Copyright © 2019 VLC authors and VideoLAN
*
* Authors: Robert Gordon <robwaynegordon@gmail.com>
*
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
// MARK: Protocol definition
@objc (VLCMediaPlaybackControlToolbarDelegate)
protocol MediaPlaybackControlToolbarDelegate: class {
func mediaPlaybackControlDidTogglePlayPause(_ mediaPlaybackControlToolbar: MediaPlaybackControlToolbar)
func mediaPlaybackControlDidSkipForward(_ mediaPlaybackControlToolbar: MediaPlaybackControlToolbar)
func mediaPlaybackControlDidSkipBackward(_ mediaPlaybackControlToolbar: MediaPlaybackControlToolbar)
func mediaPlaybackControlDidSkipToNextMedia(_ mediaPlaybackControlToolbar: MediaPlaybackControlToolbar)
func mediaPlaybackControlDidSkipToPreviousMedia(_ mediaPlaybackControlToolbar: MediaPlaybackControlToolbar)
}
@objc (VLCMediaPlaybackControlToolbar)
@objcMembers class MediaPlaybackControlToolbar: UIStackView {
// MARK: Instance Variables
weak var delegate: MediaPlaybackControlToolbarDelegate?
lazy var playPauseButton: UIButton = {
var playBtn = UIButton(type: .system)
playBtn.addTarget(self, action: #selector(togglePlayPause), for: .touchUpInside)
playBtn.setImage(UIImage(named: "iconPause"), for: .normal)
playBtn.tintColor = .white
return playBtn
}()
lazy var skipForwardButton: UIButton = {
var fwdButton = UIButton(type: .system)
fwdButton.setImage(UIImage(named: "iconSkipForward"), for: .normal)
fwdButton.addTarget(self, action: #selector(skipForward), for: .touchUpInside)
fwdButton.tintColor = .white
return fwdButton
}()
lazy var skipBackwardButton: UIButton = {
var bwdButton = UIButton(type: .system)
bwdButton.setImage(UIImage(named: "iconSkipBackward"), for: .normal)
bwdButton.addTarget(self, action: #selector(skipBackward), for: .touchUpInside)
bwdButton.tintColor = .white
return bwdButton
}()
lazy var skipToPreviousMediaButton: UIButton = {
var previousMediaButton = UIButton(type: .system)
previousMediaButton.setImage(UIImage(named: "iconSkipToPrevious"), for: .normal)
previousMediaButton.addTarget(self, action: #selector(skipForward), for: .touchUpInside)
previousMediaButton.tintColor = .white
return previousMediaButton
}()
lazy var skipToNextMediaButton: UIButton = {
var nextMediaButton = UIButton(type: .system)
nextMediaButton.setImage(UIImage(named: "iconSkipToNext"), for: .normal)
nextMediaButton.addTarget(self, action: #selector(skipForward), for: .touchUpInside)
nextMediaButton.tintColor = .white
return nextMediaButton
}()
var isPlaying: Bool {
didSet {
if isPlaying {
playPauseButton.setImage(UIImage(named: "iconPause"), for: .normal)
} else {
playPauseButton.setImage(UIImage(named: "iconPlay"), for: .normal)
}
}
}
// MARK: Initializers
required init(coder: NSCoder) {
fatalError("init(coder:) not implemented")
}
override init(frame: CGRect) {
isPlaying = true
super.init(frame: frame)
axis = .horizontal
addArrangedSubview(skipBackwardButton)
addArrangedSubview(skipToPreviousMediaButton)
addArrangedSubview(playPauseButton)
addArrangedSubview(skipToNextMediaButton)
addArrangedSubview(skipForwardButton)
}
// MARK: Button Action Methods
func togglePlayPause() {
assert(delegate != nil, "Delegate for MediaPlaybackControlToolBar not set.")
delegate?.mediaPlaybackControlDidTogglePlayPause(self)
}
func skipForward() {
assert(delegate != nil, "Delegate for MediaPlaybackControlToolBar not set.")
delegate?.mediaPlaybackControlDidSkipForward(self)
}
func skipBackward() {
assert(delegate != nil, "Delegate for MediaPlaybackControlToolBar not set.")
delegate?.mediaPlaybackControlDidSkipBackward(self)
}
func skipToPreviousMedia() {
assert(delegate != nil, "Delegate for MediaPlaybackControlToolBar not set.")
delegate?.mediaPlaybackControlDidSkipToPreviousMedia(self)
}
func skipToNextMedia() {
assert(delegate != nil, "Delegate for MediaPlaybackControlToolBar not set.")
delegate?.mediaPlaybackControlDidSkipToNextMedia(self)
}
}
......@@ -381,8 +381,9 @@
DDF908D01CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908CF1CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.m */; };
DDF908E01CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908DF1CF4E04A00108B70 /* VLCNetworkLoginDataSourceSavedLogins.m */; };
DDF908E41CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF908E31CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m */; };
E016D07322B0FB4B009FC7CA /* VideoOptionsControlBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E016D07222B0FB4B009FC7CA /* VideoOptionsControlBar.swift */; };
E03DECA622BEE27E00F44A05 /* MediaNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E03DECA522BEE27E00F44A05 /* MediaNavigationBar.swift */; };
E0539E8C22E5E2EC009317CB /* VideoOptionsControlBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0539E8B22E5E2EC009317CB /* VideoOptionsControlBar.swift */; };
E0BA21B922D7C8C700937CFD /* MediaPlaybackControlToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0BA21B822D7C8C700937CFD /* MediaPlaybackControlToolbar.swift */; };
E0C04F951A25B4410080331A /* VLCDocumentPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */; };
/* End PBXBuildFile section */
......@@ -1008,8 +1009,9 @@
DDF908E11CF4E70900108B70 /* VLCNetworkLoginDataSourceSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkLoginDataSourceSection.h; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceSection.h; sourceTree = SOURCE_ROOT; };
DDF908E21CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNetworkLoginDataSourceProtocol.h; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceProtocol.h; sourceTree = SOURCE_ROOT; };
DDF908E31CFCD97400108B70 /* VLCNetworkLoginDataSourceProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNetworkLoginDataSourceProtocol.m; path = Sources/LocalNetworkConnectivity/VLCNetworkLoginDataSourceProtocol.m; sourceTree = SOURCE_ROOT; };
E016D07222B0FB4B009FC7CA /* VideoOptionsControlBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = VideoOptionsControlBar.swift; path = Sources/VideoOptionsControlBar.swift; sourceTree = "<group>"; };
E03DECA522BEE27E00F44A05 /* MediaNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MediaNavigationBar.swift; path = Sources/MediaNavigationBar.swift; sourceTree = "<group>"; };
E0539E8B22E5E2EC009317CB /* VideoOptionsControlBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = VideoOptionsControlBar.swift; path = Sources/VideoOptionsControlBar.swift; sourceTree = "<group>"; };
E0BA21B822D7C8C700937CFD /* MediaPlaybackControlToolbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaPlaybackControlToolbar.swift; path = Sources/MediaPlaybackControlToolbar.swift; sourceTree = "<group>"; };
E0C04F931A25B4410080331A /* VLCDocumentPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCDocumentPickerController.h; path = Sources/VLCDocumentPickerController.h; sourceTree = SOURCE_ROOT; };
E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCDocumentPickerController.m; path = Sources/VLCDocumentPickerController.m; sourceTree = SOURCE_ROOT; };
E39E49F085F7C54D2DB79534 /* Pods-VLC-iOSTests.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOSTests.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-iOSTests/Pods-VLC-iOSTests.distribution.xcconfig"; sourceTree = "<group>"; };
......@@ -1254,7 +1256,7 @@
7D31CF061746AEF2005997E0 /* UI Elements */ = {
isa = PBXGroup;
children = (
E016D07222B0FB4B009FC7CA /* VideoOptionsControlBar.swift */,
E0539E8B22E5E2EC009317CB /* VideoOptionsControlBar.swift */,
41B93BFF1A53833B00102E8B /* VLCProgressView.h */,
41B93C001A53833B00102E8B /* VLCProgressView.m */,
7D3784B2183A9938009EE944 /* UIBarButtonItem+Theme.h */,
......@@ -1376,6 +1378,7 @@
7D5F7AB9175265B2006CCCFA /* Playback */ = {
isa = PBXGroup;
children = (
E0BA21B822D7C8C700937CFD /* MediaPlaybackControlToolbar.swift */,
8D144D6122298E5800984C46 /* MiniPlayer */,
416443852048419E00CAC646 /* DeviceMotion.swift */,
DD8F842F1B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.h */,
......@@ -2879,6 +2882,7 @@
7D92897A1877467E009108FD /* VLCFirstStepsCloudViewController.m in Sources */,
DD3EFF391BDEBCE500B68579 /* VLCLocalNetworkServiceVLCMedia.m in Sources */,
DD3EFF5D1BDEBCE500B68579 /* VLCLocalServerDiscoveryController.m in Sources */,
E0539E8C22E5E2EC009317CB /* VideoOptionsControlBar.swift in Sources */,
D6E034ED1CC284FC0037F516 /* VLCStreamingHistoryCell.m in Sources */,
DD3EFEED1BDEBA3800B68579 /* VLCNetworkServerBrowserViewController.m in Sources */,
8DF9669D2113317E00D0FCD6 /* EditToolbar.swift in Sources */,
......@@ -2993,7 +2997,6 @@
7D5CAA8C1A4AD8E5003F2CBC /* VLCTrackSelectorHeaderView.m in Sources */,
DD870E951CEF78D800BBD4FE /* VLCNetworkLoginDataSourceLogin.m in Sources */,
CAC0AFED20CF8F6F00EDB035 /* VLCAccessibilityIdentifier.swift in Sources */,
E016D07322B0FB4B009FC7CA /* VideoOptionsControlBar.swift in Sources */,
41701546209B36E800802E44 /* VLCPagingViewController.swift in Sources */,
7D398DC11CC3E709002C999A /* VLCLocalNetworkServiceBrowserBonjour.m in Sources */,
7D30F3CA183AB27A00FFC021 /* VLCDownloadViewController.m in Sources */,
......@@ -3016,6 +3019,7 @@
414396C22023316C005E3FAF /* AppearanceManager.swift in Sources */,
7D30F3DC183AB2F900FFC021 /* VLCNetworkLoginViewController.m in Sources */,
8DE18890210B53E000A091D2 /* TrackModel.swift in Sources */,
E0BA21B922D7C8C700937CFD /* MediaPlaybackControlToolbar.swift in Sources */,
8DE18898210F144B00A091D2 /* GenreModel.swift in Sources */,
419A2C661F37A4B70069D224 /* VLCStringsForLocalization.m in Sources */,
D0AF091F220A741300076D07 /* VLCCloudSortingSpecifierManager.swift in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "subtitlesIcon-new.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "subtitlesIcon-new@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "subtitlesIcon-new@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment