[英]IOS not playing urls from google cloud storage
I am storing my MP4 videos in google cloud storage and trying to play them in iOS device using MPMoviePlayerController but it is not playing. 我将我的MP4视频存储在Google云端存储中,并尝试使用MPMoviePlayerController在iOS设备中播放它们,但未播放。 However if I upload same file on dropbox to public, it plays fine.
但是,如果我在Dropbox上将相同文件上传到公共位置,则可以正常播放。
let videoURLWithPath = "https://storage.googleapis.com/pioctave/577265bce6058511008a39dd/57bc34d5683eb51100173a46-video/pioctave.mp4"
print(videoURLWithPath)
let videoURL = NSURL(string: videoURLWithPath)
moviePlayer = MPMoviePlayerController(contentURL: videoURL)
moviePlayer.view.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.header_video_img!.frame.size.height)
self.view.addSubview(moviePlayer.view)
moviePlayer.fullscreen = false
moviePlayer.shouldAutoplay = true
moviePlayer.controlStyle = MPMovieControlStyle.Fullscreen
moviePlayer.scalingMode = MPMovieScalingMode.AspectFill
moviePlayer.play()
I used the same file from GCS in android, it worked fine. 我在android中使用了来自GCS的相同文件,效果很好。 Following is the sample public url to the video.
以下是该视频的示例公共网址。
https://storage.googleapis.com/pioctave/577265bce6058511008a39dd/57bc34d5683eb51100173a46-video/pioctave.mp4 https://storage.googleapis.com/pioctave/577265bce6058511008a39dd/57bc34d5683eb51100173a46-video/pioctave.mp4
Is there any header issue or is there some issue in device side. 设备头是否存在任何标题问题? Please help.
请帮忙。
MPMoviePlayerController is deprecated. 不推荐使用MPMoviePlayerController。 Use AVPlayerViewController instead of MPMoviePlayerController.
使用AVPlayerViewController而不是MPMoviePlayerController。
Here is the code: 这是代码:
let videoURL = NSURL(string: "https://storage.googleapis.com/pioctave/577265bce6058511008a39dd/57bc34d5683eb51100173a46-video/pioctave.mp4")
let player = AVPlayer(url: videoURL! as URL)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.