Commit d57be5a9 authored by Carola Nitz's avatar Carola Nitz

External playback: fix display of playing externally View

Refactor some code of chromecast and external displays
parent 35b39ff0
...@@ -31,9 +31,7 @@ ...@@ -31,9 +31,7 @@
<outlet property="playbackSpeedLabel" destination="181" id="194"/> <outlet property="playbackSpeedLabel" destination="181" id="194"/>
<outlet property="playbackSpeedSlider" destination="180" id="191"/> <outlet property="playbackSpeedSlider" destination="180" id="191"/>
<outlet property="playbackSpeedView" destination="176" id="197"/> <outlet property="playbackSpeedView" destination="176" id="197"/>
<outlet property="playingExternallyDescription" destination="124" id="132"/> <outlet property="playingExternalView" destination="123" id="BVQ-JJ-Ckd"/>
<outlet property="playingExternallyTitle" destination="125" id="133"/>
<outlet property="playingExternallyView" destination="123" id="131"/>
<outlet property="resetVideoFilterButton" destination="142" id="175"/> <outlet property="resetVideoFilterButton" destination="142" id="175"/>
<outlet property="saturationLabel" destination="150" id="166"/> <outlet property="saturationLabel" destination="150" id="166"/>
<outlet property="saturationSlider" destination="149" id="168"/> <outlet property="saturationSlider" destination="149" id="168"/>
...@@ -209,7 +207,7 @@ ...@@ -209,7 +207,7 @@
</button> </button>
</subviews> </subviews>
</view> </view>
<view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" id="123" userLabel="Playing Externally View"> <view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" id="123" userLabel="Playing Externally View" customClass="VLCPlayingExternallyView" customModule="VLC_iOS" customModuleProvider="target">
<rect key="frame" x="184" y="312" width="400" height="400"/> <rect key="frame" x="184" y="312" width="400" height="400"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews> <subviews>
...@@ -217,16 +215,16 @@ ...@@ -217,16 +215,16 @@
<rect key="frame" x="51" y="0.0" width="298" height="266"/> <rect key="frame" x="51" y="0.0" width="298" height="266"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView> </imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="TV Connected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="125"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" misplaced="YES" text="TV Connected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="125">
<rect key="frame" x="51" y="274" width="298" height="21"/> <rect key="frame" x="10" y="274" width="380" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="19"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="19"/>
<color key="textColor" red="0.3803921569" green="0.3803921569" blue="0.3803921569" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.3803921569" green="0.3803921569" blue="0.3803921569" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="This video is playing on the TV" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="124"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" misplaced="YES" text="This video is playing on the TV" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="124">
<rect key="frame" x="51" y="303" width="298" height="53"/> <rect key="frame" x="10" y="303" width="380" height="53"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/> <fontDescription key="fontDescription" type="system" pointSize="16"/>
...@@ -235,6 +233,10 @@ ...@@ -235,6 +233,10 @@
</label> </label>
</subviews> </subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="playingExternallyDescription" destination="124" id="Z9R-mg-THz"/>
<outlet property="playingExternallyTitle" destination="125" id="mLx-iH-3bI"/>
</connections>
</view> </view>
<label hidden="YES" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Status Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="205" customClass="VLCStatusLabel"> <label hidden="YES" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Status Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="205" customClass="VLCStatusLabel">
<rect key="frame" x="224" y="799" width="320" height="21"/> <rect key="frame" x="224" y="799" width="320" height="21"/>
...@@ -340,7 +342,7 @@ ...@@ -340,7 +342,7 @@
</view> </view>
</objects> </objects>
<resources> <resources>
<image name="PlayingExternally.png" width="261" height="195"/> <image name="PlayingExternally.png" width="16" height="16"/>
<image name="resetIcon.png" width="24" height="30"/> <image name="resetIcon.png" width="24" height="30"/>
</resources> </resources>
</document> </document>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCPlayExternallyController" customModule="VLC_iOS" customModuleProvider="target">
<connections>
<outlet property="playingExternallyView" destination="Jhp-Wu-Cyf" id="RR8-dQ-7yL"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" id="Jhp-Wu-Cyf" userLabel="Playing Externally View" customClass="VLCPlayingExternallyView" customModule="VLC_iOS" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" fixedFrame="YES" image="PlayingExternally.png" translatesAutoresizingMaskIntoConstraints="NO" id="CIh-qH-85s">
<rect key="frame" x="108" y="20" width="160" height="130"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" fixedFrame="YES" text="TV Connected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="R6g-jM-6Ym">
<rect key="frame" x="38" y="170" width="300" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="19"/>
<color key="textColor" red="0.3803921569" green="0.3803921569" blue="0.3803921569" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" fixedFrame="YES" text="This video is playing on the TV" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UbH-6k-6hM">
<rect key="frame" x="38" y="199" width="300" height="53"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.3803921569" green="0.3803921569" blue="0.3803921569" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="highlightedColor" red="0.3803921569" green="0.3803921569" blue="0.3803921569" alpha="0.81000000000000005" colorSpace="custom" customColorSpace="sRGB"/>
</label>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="FRP-Rv-V1R"/>
<connections>
<outlet property="playingExternallyDescription" destination="UbH-6k-6hM" id="hCM-jy-NE0"/>
<outlet property="playingExternallyTitle" destination="R6g-jM-6Ym" id="3uP-nO-Yij"/>
</connections>
<point key="canvasLocation" x="122" y="-38"/>
</view>
</objects>
<resources>
<image name="PlayingExternally.png" width="16" height="16"/>
</resources>
</document>
/*****************************************************************************
* VLCPlayingExternallyView.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
class VLCPlayingExternallyView: UIView {
@IBOutlet weak var playingExternallyTitle: UILabel!
@IBOutlet weak var playingExternallyDescription: UILabel!
@objc var displayView: UIView? {
return externalWindow?.rootViewController?.view
}
var externalWindow: UIWindow?
@objc func shouldDisplay(_ show: Bool) {
self.isHidden = !show
externalWindow?.isHidden = !show
if show {
guard let screen = UIScreen.screens.count > 1 ? UIScreen.screens[1] : nil else {
return
}
screen.overscanCompensation = .none
externalWindow = UIWindow(frame: screen.bounds)
guard let externalWindow = externalWindow else {
return
}
externalWindow.rootViewController = VLCExternalDisplayController()
externalWindow.screen = screen
externalWindow.rootViewController?.view.frame = externalWindow.bounds
} else {
externalWindow = nil
}
}
override func awakeFromNib() {
playingExternallyTitle.text = NSLocalizedString("PLAYING_EXTERNALLY_TITLE", comment: "")
playingExternallyDescription.text = NSLocalizedString("PLAYING_EXTERNALLY_DESC", comment:"")
}
@objc func updateUI(rendererItem: VLCRendererItem?) {
if let rendererItem = rendererItem {
playingExternallyTitle.text = NSLocalizedString("PLAYING_EXTERNALLY_TITLE_CHROMECAST", comment:"")
playingExternallyDescription.text = rendererItem.name;
} else {
playingExternallyTitle.text = NSLocalizedString("PLAYING_EXTERNALLY_TITLE", comment: "")
playingExternallyDescription.text = NSLocalizedString("PLAYING_EXTERNALLY_DESC", comment:"")
}
}
}
...@@ -35,10 +35,6 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) { ...@@ -35,10 +35,6 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
@property (nonatomic, strong) IBOutlet UIButton *sleepTimerButton; @property (nonatomic, strong) IBOutlet UIButton *sleepTimerButton;
@property (nonatomic, strong) IBOutlet VLCStatusLabel *statusLabel; @property (nonatomic, strong) IBOutlet VLCStatusLabel *statusLabel;
@property (nonatomic, strong) IBOutlet UIView *playingExternallyView;
@property (nonatomic, strong) IBOutlet UILabel *playingExternallyTitle;
@property (nonatomic, strong) IBOutlet UILabel *playingExternallyDescription;
@property (nonatomic, strong) IBOutlet VLCFrostedGlasView *videoFilterView; @property (nonatomic, strong) IBOutlet VLCFrostedGlasView *videoFilterView;
@property (nonatomic, strong) IBOutlet UILabel *hueLabel; @property (nonatomic, strong) IBOutlet UILabel *hueLabel;
@property (nonatomic, strong) IBOutlet UISlider *hueSlider; @property (nonatomic, strong) IBOutlet UISlider *hueSlider;
...@@ -96,6 +92,4 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) { ...@@ -96,6 +92,4 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
- (void)toggleChapterAndTitleSelector; - (void)toggleChapterAndTitleSelector;
- (void)hideMenu; - (void)hideMenu;
- (void)setupCastWithCurrentRenderer;
@end @end
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
*****************************************************************************/ *****************************************************************************/
#import "VLCMovieViewController.h" #import "VLCMovieViewController.h"
#import "VLCExternalDisplayController.h"
#import "VLCEqualizerView.h" #import "VLCEqualizerView.h"
#import "VLCMultiSelectionMenuView.h" #import "VLCMultiSelectionMenuView.h"
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
...@@ -122,7 +121,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -122,7 +121,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
} }
@property (nonatomic, strong) VLCMovieViewControlPanelView *controllerPanel; @property (nonatomic, strong) VLCMovieViewControlPanelView *controllerPanel;
@property (nonatomic, strong) UIPopoverController *masterPopoverController; @property (nonatomic, strong) UIPopoverController *masterPopoverController;
@property (nonatomic, strong) UIWindow *externalWindow; @property (nonatomic, strong) IBOutlet VLCPlayingExternallyView *playingExternalView;
@end @end
@implementation VLCMovieViewController @implementation VLCMovieViewController
...@@ -196,9 +196,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -196,9 +196,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
name:VLCPlaybackControllerPlaybackDidStop name:VLCPlaybackControllerPlaybackDidStop
object:nil]; object:nil];
if ([[UIDevice currentDevice] VLCHasExternalDisplay])
[self showOnExternalDisplay];
self.trackNameLabel.text = self.artistNameLabel.text = self.albumNameLabel.text = @""; self.trackNameLabel.text = self.artistNameLabel.text = self.albumNameLabel.text = @"";
_movieView.userInteractionEnabled = NO; _movieView.userInteractionEnabled = NO;
...@@ -434,8 +431,9 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -434,8 +431,9 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
VLCRendererDiscovererManager *manager = [VLCRendererDiscovererManager sharedInstance]; VLCRendererDiscovererManager *manager = [VLCRendererDiscovererManager sharedInstance];
manager.presentingViewController = self; manager.presentingViewController = self;
manager.delegate = self; manager.delegate = self;
if (_vpc.renderer || [[UIDevice currentDevice] VLCHasExternalDisplay]) {
[self hidePlayingExternallyViewForRendererIfNeeded]; [self showOnDisplay:_playingExternalView.displayView];
}
} }
- (void)viewDidAppear:(BOOL)animated - (void)viewDidAppear:(BOOL)animated
...@@ -895,7 +893,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -895,7 +893,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (IBAction)closePlayback:(id)sender - (IBAction)closePlayback:(id)sender
{ {
_playbackWillClose = YES; _playbackWillClose = YES;
[self hidePlayingExternallyViewForRendererIfNeeded];
[_vpc stopPlayback]; [_vpc stopPlayback];
} }
...@@ -1080,10 +1077,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1080,10 +1077,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[_controllerPanel updateButtons]; [_controllerPanel updateButtons];
_audioOnly = metadata.isAudioOnly; _audioOnly = metadata.isAudioOnly;
if (_audioOnly) {
// fixme: _playingExternallyView should be shown in audioOnly as well
_playingExternallyView.hidden = YES;
}
} }
- (IBAction)playPause - (IBAction)playPause
...@@ -1685,81 +1678,35 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1685,81 +1678,35 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
#pragma mark - External Display #pragma mark - External Display
- (void)showOnExternalDisplay - (void)showOnDisplay:(UIView *)view
{ {
UIScreen *screen = [UIScreen screens][1]; BOOL displayExternally = view != _movieView;
screen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame; [_playingExternalView shouldDisplay:displayExternally];
[_playingExternalView updateUIWithRendererItem:_vpc.renderer];
self.externalWindow = [[UIWindow alloc] initWithFrame:screen.bounds]; _vpc.videoOutputView = view;
_artworkImageView.hidden = displayExternally;
UIViewController *controller = [[VLCExternalDisplayController alloc] init];
self.externalWindow.rootViewController = controller;
[controller.view addSubview:_movieView];
controller.view.frame = screen.bounds;
_movieView.frame = screen.bounds;
self.playingExternallyView.hidden = NO;
self.externalWindow.screen = screen;
self.externalWindow.hidden = NO;
_playingExternallyTitle.text = NSLocalizedString(@"PLAYING_EXTERNALLY_TITLE", nil);
_playingExternallyDescription.text = NSLocalizedString(@"PLAYING_EXTERNALLY_DESC", nil);
}
- (void)hideFromExternalDisplay
{
[self.view addSubview:_movieView];
[self.view sendSubviewToBack:_movieView];
_movieView.frame = self.view.frame;
self.playingExternallyView.hidden = YES;
self.externalWindow.hidden = YES;
self.externalWindow = nil;
} }
- (void)handleExternalScreenDidConnect:(NSNotification *)notification - (void)handleExternalScreenDidConnect:(NSNotification *)notification
{ {
[self showOnExternalDisplay]; [self showOnDisplay:_playingExternalView.displayView];
} }
- (void)handleExternalScreenDidDisconnect:(NSNotification *)notification - (void)handleExternalScreenDidDisconnect:(NSNotification *)notification
{ {
[self hideFromExternalDisplay]; [self showOnDisplay:_movieView];
} }
#pragma mark - Renderers #pragma mark - Renderers
/**
* Checks if playingExternallyView needs to be hidden.
* If not, playingExternallyView will be shown with the current renderer name
*/
- (void)hidePlayingExternallyViewForRendererIfNeeded
{
VLCRendererItem *renderer = _vpc.renderer;
if (renderer != nil) {
// TODO: Have a better/prettier transition between local playback frame and playingExternallyView
_playingExternallyView.hidden = NO;
_playingExternallyTitle.text = NSLocalizedString(@"PLAYING_EXTERNALLY_TITLE_CHROMECAST", nil);
_playingExternallyDescription.text = renderer.name;
} else {
_playingExternallyView.hidden = YES;
}
}
- (void)setupCastWithCurrentRenderer
{
[self hidePlayingExternallyViewForRendererIfNeeded];
[_vpc mediaPlayerSetRenderer:_vpc.renderer];
}
- (void)setupRendererDiscovererManager - (void)setupRendererDiscovererManager
{ {
// Create a renderer button for VLCMovieViewController // Create a renderer button for VLCMovieViewController
_rendererButton = [VLCRendererDiscovererManager.sharedInstance setupRendererButton]; _rendererButton = [VLCRendererDiscovererManager.sharedInstance setupRendererButton];
[VLCRendererDiscovererManager.sharedInstance addSelectionHandlerWithSelectionHandler:^(VLCRendererItem * _Nonnull item) { [VLCRendererDiscovererManager.sharedInstance addSelectionHandlerWithSelectionHandler:^(VLCRendererItem * item) {
[self setupCastWithCurrentRenderer]; if (item) {
[self showOnDisplay:_playingExternalView.displayView];
}
}]; }];
} }
...@@ -1767,7 +1714,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1767,7 +1714,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)removedCurrentRendererItem:(VLCRendererItem *)item - (void)removedCurrentRendererItem:(VLCRendererItem *)item
{ {
[self hidePlayingExternallyViewForRendererIfNeeded]; [self showOnDisplay:_movieView];
} }
@end @end
...@@ -136,6 +136,4 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -136,6 +136,4 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index subtitlesFilePath:(NSString *)subsFilePath; - (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index subtitlesFilePath:(NSString *)subsFilePath;
- (void)openVideoSubTitlesFromFile:(NSString *)pathToFile; - (void)openVideoSubTitlesFromFile:(NSString *)pathToFile;
- (void)mediaPlayerSetRenderer:(VLCRendererItem *)renderer;
@end @end
...@@ -1326,10 +1326,10 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) { ...@@ -1326,10 +1326,10 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
} }
#pragma mark - Renderer #pragma mark - Renderer
- (void)setRenderer:(VLCRendererItem *)renderer
- (void)mediaPlayerSetRenderer:(VLCRendererItem *)renderer
{ {
[_mediaPlayer setRendererItem:renderer]; _renderer = renderer;
[_mediaPlayer setRendererItem:_renderer];
} }
@end @end
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
*****************************************************************************/ *****************************************************************************/
@objc protocol VLCRendererDiscovererManagerDelegate { @objc protocol VLCRendererDiscovererManagerDelegate {
@objc(removedCurrentRendererItem:) @objc optional func removedCurrentRendererItem(_ item: VLCRendererItem)
optional func removedCurrentRendererItem(item: VLCRendererItem)
} }
class VLCRendererDiscovererManager: NSObject { class VLCRendererDiscovererManager: NSObject {
...@@ -116,12 +115,14 @@ class VLCRendererDiscovererManager: NSObject { ...@@ -116,12 +115,14 @@ class VLCRendererDiscovererManager: NSObject {
} }
} }
@objc func addSelectionHandler(selectionHandler: ((_ rendererItem: VLCRendererItem) -> Void)?) { @objc func addSelectionHandler(selectionHandler: ((_ rendererItem: VLCRendererItem?) -> Void)?) {
actionSheet.setAction { [weak self] (item) in actionSheet.setAction { [weak self] (item) in
if let rendererItem = item as? VLCRendererItem { if let rendererItem = item as? VLCRendererItem {
//if we select the same renderer we want to disconnect
let oldRenderer = VLCPlaybackController.sharedInstance().renderer
self?.setRendererItem(rendererItem: rendererItem) self?.setRendererItem(rendererItem: rendererItem)
if let handler = selectionHandler { if let handler = selectionHandler {
handler(rendererItem) handler(oldRenderer == rendererItem ? nil : rendererItem)
} }
} }
} }
...@@ -164,11 +165,7 @@ extension VLCRendererDiscovererManager: VLCRendererDiscovererDelegate { ...@@ -164,11 +165,7 @@ extension VLCRendererDiscovererManager: VLCRendererDiscovererDelegate {
// Current renderer has been removed // Current renderer has been removed
if playbackController.renderer == item { if playbackController.renderer == item {
playbackController.renderer = nil playbackController.renderer = nil
if playbackController.isPlaying { delegate?.removedCurrentRendererItem?(item)
// If playing, fall back to local playback
playbackController.mediaPlayerSetRenderer(nil)
}
delegate?.removedCurrentRendererItem?(item: item)
// Reset buttons state // Reset buttons state
for button in rendererButtons { for button in rendererButtons {
button.isSelected = false button.isSelected = false
...@@ -230,6 +227,8 @@ extension VLCRendererDiscovererManager: VLCActionSheetDelegate { ...@@ -230,6 +227,8 @@ extension VLCRendererDiscovererManager: VLCActionSheetDelegate {
if !isCurrentlySelectedRenderer { if !isCurrentlySelectedRenderer {
collectionView.reloadData() collectionView.reloadData()
} else {
delegate?.removedCurrentRendererItem?(renderer)
} }
updateCollectionViewCellApparence(cell: cell, highlighted: isCurrentlySelectedRenderer) updateCollectionViewCellApparence(cell: cell, highlighted: isCurrentlySelectedRenderer)
} }
......
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
#import <PAPasscode/PAPasscodeViewController.h> #import <PAPasscode/PAPasscodeViewController.h>
#import <XKKeychain/XKKeychain.h> #import <XKKeychain/XKKeychain.h>
#import "VLCConstants.h" #import "VLCConstants.h"
#import "VLCExternalDisplayController.h"
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "UIColor+Presets.h" #import "UIColor+Presets.h"
...@@ -16,9 +16,10 @@ ...@@ -16,9 +16,10 @@
412BE7531FC4947400ACCC42 /* VLCMediaData+VLCDragAndDrop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412BE7521FC4947400ACCC42 /* VLCMediaData+VLCDragAndDrop.swift */; }; 412BE7531FC4947400ACCC42 /* VLCMediaData+VLCDragAndDrop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 412BE7521FC4947400ACCC42 /* VLCMediaData+VLCDragAndDrop.swift */; };
4144C4661A0ED6C700918C89 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784E6183A99E1009EE944 /* Reachability.m */; }; 4144C4661A0ED6C700918C89 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784E6183A99E1009EE944 /* Reachability.m */; };
4152F1621FEF19BD00F1908B /* KeychainCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4152F1611FEF19BD00F1908B /* KeychainCoordinator.swift */; }; 4152F1621FEF19BD00F1908B /* KeychainCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4152F1611FEF19BD00F1908B /* KeychainCoordinator.swift */; };
416443862048419E00CAC646 /* DeviceMotion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 416443852048419E00CAC646 /* DeviceMotion.swift */; };
416DACB720B6DB9A001BC75D /* VLCPlayingExternallyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 416DACB620B6DB9A001BC75D /* VLCPlayingExternallyView.swift */; };
416DEFF61FEEA76A00F4FC59 /* LayoutAnchorContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 416DEFF51FEEA76A00F4FC59 /* LayoutAnchorContainer.swift */; }; 416DEFF61FEEA76A00F4FC59 /* LayoutAnchorContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 416DEFF51FEEA76A00F4FC59 /* LayoutAnchorContainer.swift */; };
4171D35018A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 4171D34F18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m */; }; 4171D35018A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 4171D34F18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m */; };
416443862048419E00CAC646 /* DeviceMotion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 416443852048419E00CAC646 /* DeviceMotion.swift */; };
417CDA231A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 417CDA211A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.m */; }; 417CDA231A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 417CDA211A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.m */; };
417CDA241A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 417CDA221A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.xib */; }; 417CDA241A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 417CDA221A48D1F300D9ACE7 /* VLCCloudServicesTableViewController.xib */; };
417D7F601F7BA26200DDF36A /* VLCRemoteControlService.m in Sources */ = {isa = PBXBuildFile; fileRef = 417D7F5F1F7BA26200DDF36A /* VLCRemoteControlService.m */; }; 417D7F601F7BA26200DDF36A /* VLCRemoteControlService.m in Sources */ = {isa = PBXBuildFile; fileRef = 417D7F5F1F7BA26200DDF36A /* VLCRemoteControlService.m */; };
...@@ -748,6 +749,7 @@ ...@@ -748,6 +749,7 @@
412BE7521FC4947400ACCC42 /* VLCMediaData+VLCDragAndDrop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "VLCMediaData+VLCDragAndDrop.swift"; path = "Sources/VLCMediaData+VLCDragAndDrop.swift"; sourceTree = SOURCE_ROOT; }; 412BE7521FC4947400ACCC42 /* VLCMediaData+VLCDragAndDrop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "VLCMediaData+VLCDragAndDrop.swift"; path = "Sources/VLCMediaData+VLCDragAndDrop.swift"; sourceTree = SOURCE_ROOT; };
4152F1611FEF19BD00F1908B /* KeychainCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = KeychainCoordinator.swift; path = Sources/KeychainCoordinator.swift; sourceTree = "<group>"; }; 4152F1611FEF19BD00F1908B /* KeychainCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = KeychainCoordinator.swift; path = Sources/KeychainCoordinator.swift; sourceTree = "<group>"; };
416443852048419E00CAC646 /* DeviceMotion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DeviceMotion.swift; path = Sources/DeviceMotion.swift; sourceTree = "<group>"; }; 416443852048419E00CAC646 /* DeviceMotion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DeviceMotion.swift; path = Sources/DeviceMotion.swift; sourceTree = "<group>"; };
416DACB620B6DB9A001BC75D /* VLCPlayingExternallyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCPlayingExternallyView.swift; sourceTree = "<group>"; };
416DEFF51FEEA76A00F4FC59 /* LayoutAnchorContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LayoutAnchorContainer.swift; path = Sources/LayoutAnchorContainer.swift; sourceTree = "<group>"; }; 416DEFF51FEEA76A00F4FC59 /* LayoutAnchorContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LayoutAnchorContainer.swift; path = Sources/LayoutAnchorContainer.swift; sourceTree = "<group>"; };
4171D34E18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCFolderCollectionViewFlowLayout.h; path = Sources/VLCFolderCollectionViewFlowLayout.h; sourceTree = SOURCE_ROOT; }; 4171D34E18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCFolderCollectionViewFlowLayout.h; path = Sources/VLCFolderCollectionViewFlowLayout.h; sourceTree = SOURCE_ROOT; };
4171D34F18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCFolderCollectionViewFlowLayout.m; path = Sources/VLCFolderCollectionViewFlowLayout.m; sourceTree = SOURCE_ROOT; }; 4171D34F18A2C19000A16EF9 /* VLCFolderCollectionViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCFolderCollectionViewFlowLayout.m; path = Sources/VLCFolderCollectionViewFlowLayout.m; sourceTree = SOURCE_ROOT; };
...@@ -2758,6 +2760,7 @@ ...@@ -2758,6 +2760,7 @@
417E68B81F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m */, 417E68B81F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m */,
41EB91DB1F7BFF8400821AA5 /* VLCMetadata.h */, 41EB91DB1F7BFF8400821AA5 /* VLCMetadata.h */,
41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */, 41EB91DC1F7BFF8400821AA5 /* VLCMetadata.m */,
416DACB620B6DB9A001BC75D /* VLCPlayingExternallyView.swift */,
); );
path = SharedSources; path = SharedSources;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -3951,6 +3954,7 @@ ...@@ -3951,6 +3954,7 @@
7D3784C2183A9938009EE944 /* VLCSlider.m in Sources */, 7D3784C2183A9938009EE944 /* VLCSlider.m in Sources */,
7D3784C3183A9938009EE944 /* VLCStatusLabel.m in Sources */, 7D3784C3183A9938009EE944 /* VLCStatusLabel.m in Sources */,
7D1276621AADA0E600F0260C /* VLCMultiSelectionMenuView.m in Sources */, 7D1276621AADA0E600F0260C /* VLCMultiSelectionMenuView.m in Sources */,
416DACB720B6DB9A001BC75D /* VLCPlayingExternallyView.swift in Sources */,
7D3784C8183A9972009EE944 /* NSString+SupportedMedia.m in Sources */, 7D3784C8183A9972009EE944 /* NSString+SupportedMedia.m in Sources */,
417E68B91F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m in Sources */, 417E68B91F321EFF00DB9BB2 /* VLCActivityViewControllerVendor.m in Sources */,
DD3EFF5B1BDEBCE500B68579 /* VLCNetworkServerBrowserUPnP.m in Sources */, DD3EFF5B1BDEBCE500B68579 /* VLCNetworkServerBrowserUPnP.m in Sources */,
......
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