Commit af54bff0 authored by Carola Nitz's avatar Carola Nitz

VLCPlaybackController: Don't show errorDialogs from VLCKit anymore

(closes #184)
parent b4ade073
/*****************************************************************************
* VLCPlaybackController+VLCDialogProvider.swift
* VLC for iOS
*****************************************************************************
* Copyright (c) 2018 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Carola Nitz <caro # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
import Foundation
extension VLCPlaybackController: VLCCustomDialogRendererProtocol {
public func showError(withTitle error: String, message: String) {
//noop
}
public func showLogin(withTitle title: String, message: String, defaultUsername username: String?, askingForStorage: Bool, withReference reference: NSValue) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
var usernameField: UITextField?
var passwordField: UITextField?
alertController.addTextField { textField in
usernameField = textField
textField.placeholder = NSLocalizedString("USER_LABEL", comment:"")
if username != "" {
textField.text = username
}
}
alertController.addTextField { textField in
passwordField = textField
textField.isSecureTextEntry = true
textField.placeholder = NSLocalizedString("PASSWORD_LABEL", comment:"")
}
let loginAction = UIAlertAction(title: NSLocalizedString("LOGIN", comment:""), style: .default) {[weak self] action in
let username = usernameField?.text ?? ""
let password = passwordField?.text ?? ""
self?.dialogProvider.postUsername(username, andPassword: password, forDialogReference: reference, store: false)
}
alertController.addAction(loginAction)
alertController.preferredAction = loginAction
alertController.addAction(UIAlertAction(title: NSLocalizedString("BUTTON_CANCEL", comment:""), style: .cancel, handler: { [weak self] action in
self?.dialogProvider.dismissDialog(withReference: reference)
}))
if askingForStorage {
alertController.addAction(UIAlertAction(title: NSLocalizedString("BUTTON_SAVE", comment:""), style: .default, handler: {[weak self] action in
let username = usernameField?.text ?? ""
let password = passwordField?.text ?? ""
self?.dialogProvider.postUsername(username, andPassword: password, forDialogReference: reference, store: true)
}))
}
UIApplication.shared.delegate?.window??.rootViewController?.presentedViewController?.present(alertController, animated: true, completion: nil)
}
public func showQuestion(withTitle title: String, message: String, type questionType: VLCDialogQuestionType, cancel cancelString: String?, action1String: String?, action2String: String?, withReference reference: NSValue) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
if let cancelTitle = cancelString {
alertController.addAction(UIAlertAction(title: cancelTitle, style: .cancel, handler: { [weak self] action in
self?.dialogProvider.postAction(3, forDialogReference: reference)
}))
}
if let action1Ttile = action1String {
let confirmAction = UIAlertAction(title: action1Ttile, style: .default, handler: { [weak self] action in
self?.dialogProvider.postAction(1, forDialogReference: reference)
})
alertController.addAction(confirmAction)
alertController.preferredAction = confirmAction
}
if let action2Title = action2String {
alertController.addAction(UIAlertAction(title: action2Title, style: .default, handler: {[weak self] action in
self?.dialogProvider.postAction(2, forDialogReference: reference)
}))
}
UIApplication.shared.delegate?.window??.rootViewController?.presentedViewController?.present(alertController, animated: true, completion: nil)
}
public func showProgress(withTitle title: String, message: String, isIndeterminate: Bool, position: Float, cancel cancelString: String?, withReference reference: NSValue) {
print("title: \(title), message: \(message), isIndeterminate: \(isIndeterminate), position: \(position), cancel: \(cancelString ?? ""), reference: \(reference)")
}
public func updateProgress(withReference reference: NSValue, message: String?, postion position: Float) {
print("reference: \(reference) message: \(message ?? "") position: \(position)")
}
public func cancelDialog(withReference reference: NSValue) {
UIApplication.shared.delegate?.window??.rootViewController?.presentedViewController?.dismiss(animated: true, completion: nil)
}
}
......@@ -24,6 +24,7 @@ extern NSString *const VLCPlaybackControllerPlaybackPositionUpdated;
@class VLCPlaybackController;
@class VLCMetaData;
@class VLCDialogProvider;
@protocol VLCPlaybackControllerDelegate <NSObject>
@optional
......@@ -90,6 +91,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property (readonly) NSNumber *playbackTime;
@property (nonatomic, readonly) NSDictionary *mediaOptionsDictionary;
@property (nonatomic, readonly) NSTimer *sleepTimer;
@property (nonatomic, readonly) VLCDialogProvider *dialogProvider;
@property (nonatomic) VLCRendererItem * _Nullable renderer;
......
......@@ -67,8 +67,6 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
NSLock *_playbackSessionManagementLock;
VLCDialogProvider *_dialogProvider;
NSMutableArray *_shuffleStack;
void (^_playbackCompletion)(BOOL success);
}
......@@ -119,7 +117,8 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
name:UIApplicationDidEnterBackgroundNotification object:nil];
_metadata = [VLCMetaData new];
_dialogProvider = [[VLCDialogProvider alloc] initWithLibrary:[VLCLibrary sharedLibrary] customUI:NO];
_dialogProvider = [[VLCDialogProvider alloc] initWithLibrary:[VLCLibrary sharedLibrary] customUI:YES];
_dialogProvider.customRenderer = self;
_playbackSessionManagementLock = [[NSLock alloc] init];
_shuffleMode = NO;
......@@ -1345,5 +1344,4 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
_renderer = renderer;
[_mediaPlayer setRendererItem:_renderer];
}
@end
......@@ -30,6 +30,7 @@
417E68B91F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m in Sources */ = {isa = PBXBuildFile; fileRef = 417E68B81F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m */; };
4184AA151A5492070063DF5A /* VLCCloudStorageController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4184AA141A5492070063DF5A /* VLCCloudStorageController.m */; };
4187112B1F78F87200317B1A /* VLC_for_iOSTestVideoCodecs.m in Sources */ = {isa = PBXBuildFile; fileRef = 4187112A1F78F87200317B1A /* VLC_for_iOSTestVideoCodecs.m */; };
418DFE9F211C93C6005D3652 /* VLCPlaybackController+VLCDialogProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418DFE9E211C93C6005D3652 /* VLCPlaybackController+VLCDialogProvider.swift */; };
419A2C661F37A4B70069D224 /* VLCStringsForLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 419A2C651F37A4B70069D224 /* VLCStringsForLocalization.m */; };
419A2C671F37A4B70069D224 /* VLCStringsForLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 419A2C651F37A4B70069D224 /* VLCStringsForLocalization.m */; };
419A2C681F37A4B70069D224 /* VLCStringsForLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 419A2C651F37A4B70069D224 /* VLCStringsForLocalization.m */; };
......@@ -809,6 +810,7 @@
4184AA131A5492070063DF5A /* VLCCloudStorageController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCCloudStorageController.h; path = Sources/VLCCloudStorageController.h; sourceTree = SOURCE_ROOT; };
4184AA141A5492070063DF5A /* VLCCloudStorageController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCCloudStorageController.m; path = Sources/VLCCloudStorageController.m; sourceTree = SOURCE_ROOT; };
4187112A1F78F87200317B1A /* VLC_for_iOSTestVideoCodecs.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLC_for_iOSTestVideoCodecs.m; sourceTree = "<group>"; };
418DFE9E211C93C6005D3652 /* VLCPlaybackController+VLCDialogProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VLCPlaybackController+VLCDialogProvider.swift"; sourceTree = "<group>"; };
419A2C651F37A4B70069D224 /* VLCStringsForLocalization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCStringsForLocalization.m; sourceTree = "<group>"; };
419D7F041F54176900AF69A2 /* VLCTimeNavigationTitleView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = VLCTimeNavigationTitleView.xib; path = Resources/VLCTimeNavigationTitleView.xib; sourceTree = SOURCE_ROOT; };
41B0BC861F73ED7D0063BA26 /* VLC for iOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "VLC for iOSUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -2276,6 +2278,7 @@
DD510B6F1B14E564003BA71C /* VLCPlayerDisplayController.m */,
417D7F5E1F7BA26200DDF36A /* VLCRemoteControlService.h */,
417D7F5F1F7BA26200DDF36A /* VLCRemoteControlService.m */,
418DFE9E211C93C6005D3652 /* VLCPlaybackController+VLCDialogProvider.swift */,
);
name = Playback;
sourceTree = "<group>";
......@@ -3885,6 +3888,7 @@
DDF908D01CF4CCAA00108B70 /* VLCNetworkLoginViewButtonCell.m in Sources */,
DD3EFF3D1BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserHTTP.m in Sources */,
DDEAECBE1BDEBF6700756C83 /* VLCNetworkServerLoginInformation.m in Sources */,
418DFE9F211C93C6005D3652 /* VLCPlaybackController+VLCDialogProvider.swift in Sources */,
7D92897A1877467E009108FD /* VLCFirstStepsFourthPageViewController.m in Sources */,
DD3EFF391BDEBCE500B68579 /* VLCLocalNetworkServiceVLCMedia.m in Sources */,
DD3EFF5D1BDEBCE500B68579 /* VLCLocalServerDiscoveryController.m in Sources */,
......
  • Carola @caro

    mentioned in commit c58e5c1d

    ·

    mentioned in commit c58e5c1d

    Toggle commit list
  • Why was this change done and how is this related to #184 (closed)?

  • @ePirat vlckit 184 and because modules would fail and produce errors and it would just try the next module and work fine. So the user would get an error message even though there was no error

  • You can reference issues in other projects like so: videolan/VLCKit#184 (This will get linked correctly by Gitlab: VLCKit#184 (closed)).

    Do you have a example of where a module produces an error even though another module might be able to handle it fine? Because I think this should never happen?

  • @ePirat ah merci :) didn't know that you could do it like that. @tguillem probably has some. I just tested with some old subtitles errors. TBH as you can see from my comments I also figured that the errordialogs shouldn't come out of libvlc if we don't want to present them but they're needed for the log UI in VLC as well from what I understood, also they're not translated

    Edited by Carola
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