这是我的所有代码播放mp4,mp4播放但没有声音
import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var containerView: UIView!
var playerLayer:AVPlayerLayer!
var player:AVPlayer!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let path = NSBundle.mainBundle().pathForResource("huoguo", ofType: "mp4")
let url = NSURL(fileURLWithPath: path!)
let asset = AVAsset(URL: url)
let playerItem = AVPlayerItem(asset: asset)
self.player = AVPlayer(playerItem: playerItem)
self.playerLayer = AVPlayerLayer(player: player)
self.playerLayer.frame = CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.width * 9 / 16)
self.containerView.layer.addSublayer(playerLayer)
//self.playerLayer.player?.volume = 1
self.playerLayer.player?.play() …Run Code Online (Sandbox Code Playgroud) 我将使用jenkins为我的iOS应用程序,我在互联网上关注一些博客并使用jenkins成功构建,但是当我想为我的项目运行测试时,我收到此错误:
2015-12-10 16:58:06.105 xcodebuild[6635:91852] iPhoneSimulator: Could not launch simulator: -10810
2015-12-10 16:58:06.174 xcodebuild[6635:92068] iPhoneSimulator: Could not launch simulator: -10810
** TEST FAILED **
Run Code Online (Sandbox Code Playgroud)
我已经尝试了xcodeplugin,只是jenkins中的一个简单的shell命令,他们都给了我这个错误.我的shell命令如下:
xcodebuild -scheme XcodeBulidDemo -destination 'platform=iOS Simulator,name=iPhone 6' -configuration Debug test
Run Code Online (Sandbox Code Playgroud)
我曾尝试在我的项目下的终端中运行此命令,它可以获得测试结果.
我真的不明白错误"iPhoneSimulator:无法启动模拟器:-10810"是什么意思,任何人都可以给我一些建议..
在文档中:
返回满足其所包含约束的视图的大小.
好的,我在storyboard中创建了一个视图,并添加了约束:
yellowview.leading = self.view.leading
yellow view.trailing = self.view.trailing
yellow view.bottom = self.view.bottom
yelloview.height = 128
Run Code Online (Sandbox Code Playgroud)
现在我打印出来systemLayoutSizeFittingSize,我希望它是UIScreen宽度和128高度.但结果是:
====UILayoutFittingCompressedSize==
(0.0, 128.0)
====UILayoutFittingExpandedSize==
(10000.0, 128.0)
Run Code Online (Sandbox Code Playgroud)
======================================
然后我创建一个视图并通过代码添加约束:
let btn :UIButton = {
let btn = UIButton(type: .Custom)
btn.backgroundColor = UIColor.redColor()
btn.translatesAutoresizingMaskIntoConstraints = false
return btn
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(btn)
btn.leadingAnchor.constraintEqualToAnchor(self.view.leadingAnchor, constant: 100).active = true
btn.trailingAnchor.constraintEqualToAnchor(self.view.trailingAnchor, constant: -100).active = true
btn.topAnchor.constraintEqualToAnchor(self.view.topAnchor, constant: 100).active = true
btn.bottomAnchor.constraintEqualToAnchor(self.view.bottomAnchor, constant: -100).active = true
}
Run Code Online (Sandbox Code Playgroud)
它显示很好:
现在打印出来了systemLayoutSizeFittingSize: …
我想记录我的 swift 项目,我在 github 上找到了 jazzy。查看指南后,我创建了一个新的简单项目并想尝试一下,这是我ViewController的一些文档信息:
import UIKit
/**
a view controller
*/
class ViewController: UIViewController {
// MARK: property
/// a simple var
var hello = 200
// MARK: Func
/// view did load
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
print(add(2, b: 2))
}
/// did receiveMemoryWarning
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/// a document …Run Code Online (Sandbox Code Playgroud)