我正在创建简单的媒体播放器我的问题是当我点击下一个按钮然后视频更改但之前视频的声音在新视频中播放3-4秒然后声音改变
这是我的代码
播放视频代码
Cross Distances
下一个按钮代码
func startplaying()
{
if a >= 0 && a <= arr.count - 1
{
println(a)
filesArray = NSFileManager.defaultManager().contentsOfDirectoryAtPath(fileDestination, error: nil)!
var predicate = NSPredicate(format: "self ENDSWITH '.mp4'", filesArray)
filesArray = filesArray.filteredArrayUsingPredicate(predicate)
videoPath = fileDestination.stringByAppendingPathComponent(arr[a])
videoPath = "file://".stringByAppendingPathComponent(videoPath)
println(arr[a])
videoPath = Utilities.Instance().urlEncoder(videoPath)
let url = NSURL(string: videoPath)
movieplayer = MPMoviePlayerController(contentURL: url)
// navigationItem.title = name
titleLabel.text = arr[a]
navigationItem.hidesBackButton = true
movieplayer.view.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height)
movieplayer.view.sizeToFit()
movieplayer.fullscreen = true
movieplayer.scalingMode = MPMovieScalingMode.AspectFit
movieplayer.fullscreen = true
movieplayer.controlStyle = MPMovieControlStyle.None
movieplayer.movieSourceType = MPMovieSourceType.File
movieplayer.play()
slider.value = 0
slider.maximumValue = Float(movieplayer.duration)
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "updateTime", userInfo: nil, repeats: true)
self.view.addSubview(movieplayer.view)
self.view.addSubview(butView)
self.view.addSubview(titleView)
}
}