我想在 Swift 中从 Internet 流式传输音频,但还没有找到正确的功能示例。
在Objective-C 中
AVPlayerItem* playerItem =[AVPlayerItem playerItemWithURL:[NSURL URLWithString:streamURL]];
[playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil];
music = [AVPlayer playerWithPlayerItem:playerItem];
[music play];
Run Code Online (Sandbox Code Playgroud)
我在Swift 中的尝试
let playerItem = AVPlayerItem(URL:NSURL(string:url))
var player:AVPlayer!
player = AVPlayer(playerItem:playerItem)
player.rate = 1.0;
player.play()
//this is not working
Run Code Online (Sandbox Code Playgroud)
我也尝试添加 playerItem.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions.New, context: nil) 但我得到了一个错误
'类 AVPlayerItem 的实例 0x16edbd20 已被释放,而键值观察者仍向其注册。当前观察信息:(上下文:0x0,属性:0x16ea5880>)'
关于如何解决这个问题的任何想法?
我有1个具有多列的表。在应用程序上,我们期待添加4个动态滤镜,例如(猫,大小,颜色,形状)。
我们知道我们可以像这样为sqllite创建一个过滤器:
user = user.select(name)
.filter((color == "Blue") && (size = "Big") && (cat="a") && (shape="round"))
.order(name.asc, name) // ORDER BY "email" DESC, "name"
.limit(5, offset: 0)
Run Code Online (Sandbox Code Playgroud)
但是,如果使用滤镜,那会发生什么呢?假设对于颜色,我们要搜索所有颜色。然后,
.filter((color == "?????") && (size = "Big") && (cat="a") && (shape="round"))
Run Code Online (Sandbox Code Playgroud)
关于如何为这种情况创建动态过滤器的任何想法?