我正在用 Swift 编写一个应用程序,我相信代码都是有效的,因为没有编译器错误。当我尝试播放我知道存在的音频文件时,出现下面列出的错误。
没有音频播放。
我尝试以不同的方式编写代码,包括使用 contentsOf 参数实例化 AVAudioPlayer。
import UIKit
import CoreML
import AVFoundation
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let soundURL = Bundle.main.url(forResource: "beep", withExtension: "mp3")!
var soundPlayer : AVAudioPlayer!
do {
soundPlayer = try AVAudioPlayer(contentsOf: soundURL)
}
catch {
print("Err")
}
soundPlayer.play()
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
2019-10-18 22:35:29.609690-040 Test[. . .] [plugin]
AddInstanceForFactory: No factory registered for id <CFUUID . . . > . .
2019-10-18 22:35:30.527132-0400 …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个运行在不同网页上的JavaScript.脚本应在搜索栏中键入内容,单击搜索,单击结果,然后将每个结果文本保存到数组中.它看起来像:
function returnresults(queries){
arrayofcontent = [];
for each query {
type query in searchbar;
submit search;
result[0].click(); // go to first result
arrayofcontent.push(pagecontent.innertext);
}
return arrayofcontent;
}Run Code Online (Sandbox Code Playgroud)
问题是脚本点击搜索后脚本似乎停止了,这让我觉得脚本在移动到另一个页面时会自行卸载,即使我在Google Chrome的javascript控制台中直接输入脚本.有没有人知道如何告诉谷歌浏览器即使在页面之间移动后仍继续运行脚本?