I encounter the some problems while trying to play the streaming movie in Mpmovieplayer. I want to prepare for streaming movie to be ready inside the load method and then start it after clicking the button(toggle play method). But sometimes it plays automatically before clicking the button. (about 20%). I don't know how to figure it out.
func load(~~~~~~~~~~~~~~~~~){
self.doPause()
self.isOnMetaData = false
self.isLive = isLivePlay
self.playURL = path
self.isFile = isFile
self.isAutoPlay = isAutoPlay
if(isFile==false && isAutoPlay==true){
if(self.checkNetworkAllow()==false){
return false
}
}
if(isAutoPlay == true){
self.loadBar?.startAnimating()
}else{
self.loadBar?.stopAnimating()
}
self.isPlaying=false
self.resetPlayerStatus()
self.setActive(true)
PlayerManager.instance!.setActivePlayer(self)
if(self.isLive == true){
self.uiSeekBox?.hidden = true
}else{
self.uiSeekBox?.hidden = false
}
print("play path : " + path)
if(isFile == true){
self.player!.contentURL = NSURL(fileURLWithPath: path)
}else{
self.player!.contentURL = NSURL(string: path)
}
let isUrl:Bool = (playURL?.containsString("bora"))! //icesky86 add
}
self.player!.shouldAutoplay = false
self.isBora = true
self.player!.prepareToPlay()
}
->> Load Method Part
func togglePlay(){
if(self.isPlaying == false){
if(self.isBora == true){
let second = 0.9
let delay = second * Double(NSEC_PER_SEC)
let dispatchTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
self.loadBar!.hidden = true
})
}
self.play()
}else{
self.pause()
}
}
Please help me .