오디오 플레이어를 만들어야합니다. URL에서 오디오를 가져오고 URL에서 오디오를 다운로드 한 다음 재생합니다. 하지만 오디오를 재생하면서 오디오를 재생해야하는 이유는 무엇입니까?URL에서 다운로드하는 동안 오디오를 재생하는 방법은 무엇입니까?
이것은 URL에서 그것을 연주하는 내 코드입니다 :
func URLSession(session: NSURLSession,
downloadTask: NSURLSessionDownloadTask,
didFinishDownloadingToURL location: NSURL){
do {
loadingView.hidden=true
actInd.stopAnimating()
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
player=try AVAudioPlayer(contentsOfURL: location)
player?.delegate=self
selectedAudio.status=true
selectedAudio.isDownload=true
player?.enableRate=true
switch speedType_Index {
case 0:
appDelegate.player?.rate=Float(1)
break
case 1:
appDelegate.player?.rate=Float(1.5)
break
case 2:
appDelegate.player?.rate=Float(2)
break
case 3:
appDelegate.player?.rate=Float(0.5)
break
default:
break
}
switch playingType_Index {
case 0:
appDelegate.player?.numberOfLoops = 0
break
case 1:
appDelegate.player?.numberOfLoops = -1
break
default:
break
}
player?.volume=Float(volume)
player?.play()
self.tableView.reloadData()
}catch let error as NSError{
print(error.localizedDescription)
}
}
func URLSession(session: NSURLSession,
downloadTask: NSURLSessionDownloadTask,
didWriteData bytesWritten: Int64,
totalBytesWritten: Int64,
totalBytesExpectedToWrite: Int64){
let progress=Float(totalBytesWritten)/Float(totalBytesExpectedToWrite);
bite.text=String(format: "%.1f%%",progress * 100)
}
슬라이더 스트리밍에서 보여주는 것처럼 스트리밍 행렬을 처리하는 방법 –
죄송합니다. 경험이 없지만 'AVPlayerViewController' (https://developer.apple.com/library/ios/)를 살펴볼 수는 있습니다. documentation/AVFoundation/Reference/AVPlayerViewController_Class /)를 사용하면 진행 상황에 대한 슬라이더를 비롯하여 컨트롤을 제공합니다. 그렇지 않으면 다른 사람도 그 문제를 겪었 기 때문에 해결책을 찾을 수 있어야합니다. 예를 들어 'AVPlayer 오디오 스트리밍 컨트롤'에 대한 인터넷 검색을 시도해보십시오. – pbodsk
도움을 주셔서 감사합니다 –