App Transport Security has blocked a cleartext HTTP 错误
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
videos.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>video_url</key>
<string>http://v.cctv.com/flash/mp4video28/TMS/2013/05/06/265114d5f2e641278098503f1676d017_h264418000nero_aac32-1.mp4</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/ae51f3deb48f8c545bc3315739292df5e0fe7fb2.jpg</string>
<key>video_title</key>
<string>艳遇2:小鲜肉</string>
<key>video_subTitle</key>
<string>邓天晴 刘帅良</string>
</dict>
<dict>
<key>video_url</key>
<string>rtmp://lm03.everyon.tv:1935/ptv3/phd4</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/9825bc315c6034a8ee0a64fbc8134954082376e4.jpg</string>
<key>video_title</key>
<string>小时代3</string>
<key>video_subTitle</key>
<string>杨幂 郭采洁</string>
</dict>
<dict>
<key>video_url</key>
<string>rtmp://lm03.everyon.tv:1935/ptv3/phd507</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/f703738da97739122ee2d869fb198618377ae2f6.jpg</string>
<key>video_title</key>
<string>医生</string>
<key>video_subTitle</key>
<string>金昌烷 裴素恩</string>
</dict>
<dict>
<key>video_url</key>
<string>http://ts.3gv.ifeng.com/live/iphone/zwt/index_multi.m3u8</string>
<key>video_img</key>
<string>http://d.hiphotos.baidu.com/video/pic/item/b3b7d0a20cf431ad9eb56c424836acaf2edd9861.jpg</string>
<key>video_title</key>
<string>不再说分手</string>
<key>video_subTitle</key>
<string>郑伊健 周秀娜</string>
</dict>
<dict>
<key>video_url</key>
<string>http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/f703738da977391224eade15fb198618377ae2f2.jpg</string>
<key>video_title</key>
<string>夜,女人</string>
<key>video_subTitle</key>
<string>王淑妍 欧定兴</string>
</dict>
<dict>
<key>video_url</key>
<string>http://v.cctv.com/flash/mp4video28/TMS/2013/05/06/265114d5f2e641278098503f1676d017_h264418000nero_aac32-1.mp4</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/ae51f3deb48f8c545bc3315739292df5e0fe7fb2.jpg</string>
<key>video_title</key>
<string>艳遇2:小鲜肉</string>
<key>video_subTitle</key>
<string>邓天晴 刘帅良</string>
</dict>
<dict>
<key>video_url</key>
<string>rtmp://lm03.everyon.tv:1935/ptv3/phd4</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/9825bc315c6034a8ee0a64fbc8134954082376e4.jpg</string>
<key>video_title</key>
<string>小时代3</string>
<key>video_subTitle</key>
<string>杨幂 郭采洁</string>
</dict>
<dict>
<key>video_url</key>
<string>rtmp://lm03.everyon.tv:1935/ptv3/phd507</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/f703738da97739122ee2d869fb198618377ae2f6.jpg</string>
<key>video_title</key>
<string>医生</string>
<key>video_subTitle</key>
<string>金昌烷 裴素恩</string>
</dict>
<dict>
<key>video_url</key>
<string>http://ts.3gv.ifeng.com/live/iphone/zwt/index_multi.m3u8</string>
<key>video_img</key>
<string>http://d.hiphotos.baidu.com/video/pic/item/b3b7d0a20cf431ad9eb56c424836acaf2edd9861.jpg</string>
<key>video_title</key>
<string>不再说分手</string>
<key>video_subTitle</key>
<string>郑伊健 周秀娜</string>
</dict>
<dict>
<key>video_url</key>
<string>http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8</string>
<key>video_img</key>
<string>http://c.hiphotos.baidu.com/video/pic/item/f703738da977391224eade15fb198618377ae2f2.jpg</string>
<key>video_title</key>
<string>夜,女人</string>
<key>video_subTitle</key>
<string>王淑妍 欧定兴</string>
</dict>
</array>
</plist>
//
// JieTableViewController.swift
// JieTableView
//
// Created by jiezhang on 14-10-5.
// Copyright (c) 2014年 jiezhang. All rights reserved.
//
import UIKit
class JieTableViewController: UITableViewController {
var listVideos : NSMutableArray!
override func viewDidLoad() {
super.viewDidLoad()
let bundle = NSBundle.mainBundle()
//读取videos.plist文件内容
let plistPath : String! = bundle.pathForResource("videos", ofType: "plist")
listVideos = NSMutableArray(contentsOfFile: plistPath)
//下面这段话是设置左边编辑,右边添加item
self.navigationItem.leftBarButtonItem = self.editButtonItem()
let addButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Add, target: self, action: "insertNewObject:")
self.navigationItem.rightBarButtonItem = addButton
}
func insertNewObject(sender: AnyObject) {
let item : NSDictionary = NSDictionary(objects:["http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8","http://c.hiphotos.baidu.com/video/pic/item/f703738da977391224eade15fb198618377ae2f2.jpg","新增数据", NSDate.description()] , forKeys: ["video_img","video_title","video_subTitle","video_url"])
listVideos.insertObject(item, atIndex: 0)
let indexPath = NSIndexPath(forRow: 0, inSection: 0)
self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//返回节的个数
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
//返回某个节中的行数
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return listVideos.count
}
//为表视图单元格提供数据,该方法是必须实现的方法
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier : String = "videoItem"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! JieTableViewCell
let row = indexPath.row
let rowDict : NSDictionary = listVideos.objectAtIndex(row) as! NSDictionary
let url : String = rowDict.objectForKey("video_img") as! String
let dataImg : NSData = NSData(contentsOfURL: NSURL(string : url)!)!
cell.JieVideoImg.image = UIImage(data: dataImg)
cell.JieVideoTitle.text = rowDict.objectForKey("video_title") as? String
cell.JieVideoSubTitle.text = rowDict.objectForKey("video_subTitle") as? String
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}
// 支持单元格编辑功能
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
listVideos.removeObjectAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
if fromIndexPath != toIndexPath{
let object: AnyObject = listVideos.objectAtIndex(fromIndexPath.row)
listVideos.removeObjectAtIndex(fromIndexPath.row)
if toIndexPath.row > self.listVideos.count{
self.listVideos.addObject(object)
}else{
self.listVideos.insertObject(object, atIndex: toIndexPath.row)
}
}
}
// Override to support conditional rearranging of the table view.
//在编辑状态,可以拖动设置item位置
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return NO if you do not want the item to be re-orderable.
return true
}
// MARK: - Navigation
//给新进入的界面进行传值
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "showDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let object : NSDictionary = listVideos[indexPath.row] as! NSDictionary
(segue.destinationViewController as! JieDetailViewController).detailItem = object
}
}
}
}
//
// JieTableViewCell.swift
// JieTableView
//
// Created by jiezhang on 14-10-5.
// Copyright (c) 2014年 jiezhang. All rights reserved.
//
import UIKit
class JieTableViewCell: UITableViewCell {
@IBOutlet weak var JieVideoImg: UIImageView!
@IBOutlet weak var JieVideoTitle: UILabel!
@IBOutlet weak var JieVideoSubTitle: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
//
// JieDetailViewController.swift
// JieTableView
//
// Created by jiezhang on 14-10-5.
// Copyright (c) 2014年 jiezhang. All rights reserved.
//
import UIKit
import MediaPlayer
class JieDetailViewController: UIViewController {
@IBOutlet var big_video_img: UIImageView!
//接受传进来的值
var detailItem: NSDictionary?
var player:MPMoviePlayerViewController!
func configureView() {
if let detail : NSDictionary = self.detailItem {
self.title = detail.objectForKey("video_title") as? String
let url : String = detail.objectForKey("video_img") as! String
let dataImg : NSData = NSData(contentsOfURL: NSURL(string : url)!)!
self.big_video_img.image = UIImage(data: dataImg)
let video_url = NSURL(string: detail.objectForKey("video_url") as! String)
player = MPMoviePlayerViewController(contentURL: video_url)
presentViewController(player, animated: true, completion: nil)
}
}
override func viewDidLoad() {
super.viewDidLoad()
configureView()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
}
}