swift编程开发swift-问题栈首页投稿(暂停使用,暂停投稿)

iOS 类似网易视频播放

2016-07-18  本文已影响322人  孤独的剑客

大致UI

Paste_Image.png

核心代码

-拉取网络数据
<p></p><pre><code>
func dataConfig() -> Void {

    DataTools.loadNewAvData("http://c.m.163.com/nc/video/home/0-10.html"){ (news) -> Void in
        guard let resultArray = news else{
            return
        }
        
        self.videoNewsArray = resultArray
        self.view .addSubview(self.basetableView)

        self.basetableView.reloadData()
        
    }

}

</code></pre>

<p></p><pre><code>
func playNewsVideo(notification:NSNotification) {

    let dict = notification.userInfo
    guard let urlStr = dict?["url"] as? String,
        let inView = dict?["inView"] as? UIView,
        let playingCell = dict?["cell"] as? VideoCell
        where urlStr != playingNewsUrl else {
            print("重复播放")
            return
    }
    
    playingPlayerView?.removeFromSuperview()
    playingPlayerView = nil
    // 处理cell重用
    self.playingCell = playingCell
    playingCellIndexPath = basetableView.indexPathForCell(playingCell)
    
    playingPlayerView = WLVideoPlayerView(url: NSURL(string: urlStr)!)
    playingPlayerView?.customControlView = controlView
    playingPlayerView?.placeholderView = UIImageView(image: UIImage(named: "302"))
    playingPlayerView?.playInView(inView)

}

</code></pre>

希望大家可可以提供一些建议。下面附上代码

[下载链接]https://git.oschina.net/mrj_mrj/videoPlayer.git

上一篇下一篇

猜你喜欢

热点阅读