我正在尝试尝试以下我找到here的解决方案:
controllers.routes.Assets.at("images/unchecked.png").absoluteURL(request())
但是我收到以下错误:
cannot find symbol symbol: method at(java.lang.String) location: variable Assets of type controllers.ReverseAssets
看起来它无法找到我认为内置的at
方法。有什么想法吗?
答案 0 :(得分:1)
这是因为您在路由器中没有使用“at”,因此它不是由Play生成的。
我想你使用版本化的
GET /assets/*file controllers.Assets.at(path="/public", file)
将其更改为“routes”文件中的“at”,然后重建项目
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
修改强>
如果您想在路线中使用版本(更好和推荐的方式),您需要采用一些“特殊”方式。 Play(2.3和2.4)在Java中存在问题(Scala版本是正确的)因此不存在Assets.versioned(String file)版本,只有Assets.versioned(资产资产)可用。所以有“特殊”的方式:
“路线”文件:
public Result index() {
...
controllers.routes.Assets.versioned(toAsset("images/unchecked.png")).absoluteURL(request())
...
}
public static controllers.Assets.Asset toAsset(String name) {
return new controllers.Assets.Asset(name);
}
控制器:
var player: AVQueuePlayer! = nil
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool)
{
super.viewDidAppear(true)
var song = AVPlayerItem(URL: NSBundle.mainBundle().URLForResource("AlmostAYearAgo", withExtension: "mp3")!)
player = AVQueuePlayer(items: [song])
let theSession = AVAudioSession.sharedInstance()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "playInterrupt:", name: AVAudioSessionInterruptionNotification, object: theSession)
player.play()
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func playInterrupt(notification: NSNotification)
{
if notification.name == AVAudioSessionInterruptionNotification && notification.userInfo != nil
{
var info = notification.userInfo!
var intValue: UInt = 0
(info[AVAudioSessionInterruptionTypeKey] as! NSValue).getValue(&intValue)
if let type = AVAudioSessionInterruptionType(rawValue: intValue)
{
switch type
{
case .Began:
print("aaaaarrrrgggg you stole me")
player.pause()
case .Ended:
let timer = NSTimer.scheduledTimerWithTimeInterval(3, target: self, selector: "resumeNow:", userInfo: nil, repeats: false)
}
}
}
}
func resumeNow(timer : NSTimer)
{
player.play()
print("attempted restart")
}
中查找“问题3”