在我的示例项目中,当点击czsm bar按钮项时,音频应继续播放而不是停止播放。
以下是列出歌曲的代码:
events {
worker_connections 1024;
}
http {
upstream node_app {
server web:3000;
}
server_tokens off;
# Define the MIME types for files.
include mime.types;
default_type application/octet-stream;
# Speed up file transfers by using sendfile()
# TODO: Read up on this
sendfile on;
server {
listen 8080;
server_name localhost;
location / {
proxy_pass http://node_app;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
以下是播放歌曲的代码,当选择一首歌曲时,它会导航到mainviewcontroller进行播放。
import Firebase
import Nuke
struct getSongIndex {
static var selectedIndex : NSInteger!
static var selectedUrl : String?
static var selectedArtistName : String?
static var selectedSongName : String?
static var arrayurl = [String]()
static var arraysongname = [String]()
static var arrayartistname = [String]()
static var arrayimageurl = [String]()
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath:
IndexPath)
{
getSongIndex.selectedIndex = indexPath.row
print("selected index is:::",getSongIndex.selectedIndex)
getSongIndex.selectedUrl = musicList[indexPath.row].songUrl
getSongIndex.selectedSongName = musicList[indexPath.row].songName
getSongIndex.selectedArtistName = musicList[indexPath.row].artistName
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier:
"ViewController") as! MainViewController
self.navigationController!.pushViewController(vc, animated: true)
}
然而,当我按下czsm按钮返回列表视图控制器时,音频应继续播放。
答案 0 :(得分:0)
var player:AVPlayer?
在课堂外声明玩家(mainviewcontroller)
现在工作正常