CardPlayer Карта не загружается - PullRequest
0 голосов
/ 28 февраля 2019

В проекте Cards https://github.com/PaoloCuscela/Cards Я скачал приложение и запустил его, и у меня возникла одна проблема с картой CardPlayer.Он не загружается при загрузке просмотра.Если щелкнуть мышью в белой области, где должна быть карта, она всплывает и становится видимой.Кажется, что информация о карте не загружается.

При загрузке просмотра

enter image description here

Когда область, в которую должна загружаться карта, нажата

enter image description here

Это то, что говорит консоль отладчика

Loaded!
CARDS: Something wrong with the video source URL
CARDS: Something wrong with the video source URL
2019-02-27 23:08:50.208 Demo[1841:237619] Failed to set (icon) user 
defined inspected property on (Cards.CardPlayer): [<Cards.CardPlayer 
0x15d7c6a0> setValue:forUndefinedKey:]: this class is not key value 
coding-compliant for the key icon.
Loaded!
2019-02-27 23:08:55.120 Demo[1841:237619] <UIVisualEffectView 
0x15e7da20> is being asked to animate its opacity. This will cause the 
effect to appear broken until opacity returns to 1.

Кто-нибудь знает, что может быть не так?

Обновление: функция расположения карт

 override open func layout(animating: Bool = true) {
    super.layout(animating: animating)

    let gimme = LayoutHelper(rect: backgroundIV.bounds)

    let aspect1016 = backgroundIV.bounds.width *  (10/16)
    let aspect921 = backgroundIV.bounds.width *  (9/21)
    let move = ( aspect1016 - aspect921 ) * 2

    subtitleLbl.transform = isPresenting ? 
CGAffineTransform(translationX: 0, y: move) : CGAffineTransform.identity
    backgroundIV.frame.size.height = originalFrame.height + ( 
isPresenting ? move/2 : 0 )
    // Issue is here: Line 208
    let currentHeigh = backgroundIV.frame.size.height
    backgroundIV.frame.size.height = originalFrame.height + ( 
isPresenting ? move/2 : 0 )

    if backgroundIV.frame.size.height <= 0 {
        print ("heigh is 0")
        backgroundIV.frame.size.height = currentHeigh
    }
    player.view.frame.origin = CGPoint.zero
    player.view.frame.size = CGSize(width: backgroundIV.bounds.width, 
height: isPresenting ? aspect1016 : aspect921 )
    playerCoverIV.frame = player.view.bounds


    playPauseV.center = player.view.center
    playIV.center = 
playPauseV.contentView.center.applying(CGAffineTransform(translationX: 
LayoutHelper.Width(5, of: playPauseV), y: 0))

    categoryLbl.frame.origin.y = gimme.Y(3, from: player.view)
    titleLbl.frame.origin.y = gimme.Y(0, from: categoryLbl)
    titleLbl.sizeToFit()

    categoryLbl.frame = CGRect(x: insets,
                               y: gimme.Y(3, from: player.view),
                               width: gimme.X(80),
                               height: gimme.Y(5))

    titleLbl.frame = CGRect(x: insets,
                            y: gimme.Y(0, from: categoryLbl),
                            width: gimme.X(70),
                            height: gimme.Y(12))
    titleLbl.sizeToFit()

    subtitleLbl.frame = CGRect(x: insets,
                               y: gimme.RevY(0, height: gimme.Y(14)) - 
insets,
                               width: gimme.X(80),
                               height: gimme.Y(12))
}


//MARK: - Actions

public func play() {

    player.playFromCurrentTime()
    UIView.animate(withDuration: 0.2) {
        self.playPauseV.transform = CGAffineTransform(scaleX: 0.1, y: 
0.1)
        self.playPauseV.alpha = 0
    }
}

public func pause() {

    player.pause()
    UIView.animate(withDuration: 0.1) {
        self.playPauseV.transform = CGAffineTransform.identity
        self.playPauseV.alpha = 1
    }
}

public func stop() {

    pause()
    player.stop()
}

@objc  func playTapped() {

    play()
    delegate?.cardPlayerDidPlay?(card: self)
}

@objc  func playerTapped() {

    pause()
    delegate?.cardPlayerDidPause?(card: self)
}

open override func touchesBegan(_ touches: Set<UITouch>, with event: 
UIEvent?) {
    if touches.first?.view == player.view || touches.first?.view == 
playPauseV.contentView { playerTapped() }
    else { super.touchesBegan(touches, with: event) }
}

}


// Player Delegates
extension CardPlayer: PlayerDelegate {
public func playerReady(_ player: Player) {

    player.view.addSubview(playPauseV)
    playPauseV.frame.size = CGSize(width: playBtnSize, height: 
playBtnSize)
    playPauseV.layer.cornerRadius = playPauseV.frame.height/2
    playIV.frame.size = CGSize(width: LayoutHelper.Width(50, of: 
playPauseV),
                               height: LayoutHelper.Width(50, of: 
playPauseV))
    playPauseV.center = player.view.center
    playIV.center = 
playPauseV.contentView.center.applying(CGAffineTransform(translationX: 
LayoutHelper.Width(5, of: playPauseV), y: 0))

    if isAutoplayEnabled {

        play()
    } else {
        pause()
    }
}

public func playerPlaybackStateDidChange(_ player: Player) { }
public func playerBufferingStateDidChange(_ player: Player) { }
public func playerBufferTimeDidChange(_ bufferTime: Double) { }
}

extension CardPlayer: PlayerPlaybackDelegate {

public func playerPlaybackDidEnd(_ player: Player) {

    if shouldRestartVideoWhenPlaybackEnds { player.playFromBeginning() 
}
    else { playerTapped()  }

}

public func playerPlaybackWillLoop(_ player: Player) { }
public func playerCurrentTimeDidChange(_ player: Player) { }
public func playerPlaybackWillStartFromBeginning(_ player: Player) { }
}

Решено Добавлено backgroundIV.frame.size.height = 300 к 208 из CardPlayer.swift

Предоставлено @Shadowsheep в чате

1 Ответ

0 голосов
/ 28 февраля 2019

Проблема относится к классу CardPlayer.swift, особенно в строке 207 (backgroundIV.frame.size.height = originalFrame.height + ( isPresenting ? move/2 : 0 ))

Когда controller загружается, установлено height из backgroundIV0.

Добавление этой проверки (в строке 207) должно решить вашу проблему.

// Issue is here
let currentHeight = backgroundIV.frame.size.height // <-- new line to store current value
/* this is line #207 */ backgroundIV.frame.size.height = originalFrame.height + ( isPresenting ? move/2 : 0 ) // This is line 207

// This is the check
if backgroundIV.frame.size.height <= 0 {
    print ("heigh is 0")
    backgroundIV.frame.size.height = currentHeight
}

Эта ошибка вместо

Failed to set (icon) user 
defined inspected property on (Cards.CardPlayer): [<Cards.CardPlayer 
0x15d7c6a0> setValue:forUndefinedKey:]: this class is not key value 
coding-compliant for the key icon.

связана спользовательский атрибут времени выполнения, заданный для представления в Main.storyboard, который не принадлежит CardPlayer (вы можете удалить его, если хотите)

enter image description here

...