VimeoNetworking
VimeoNetworking copied to clipboard
Video files are nil / Can't Play Videos / Documentation is out of date
I bought a pro account so I can play videos in my app. All I wanted was a simple tutorial on how to play videos in my account in my app. I've been at this for hours now. I followed the documentation, which is out of date by the way as noted by other open issues, and no matter what I do "files" always return nil. Which I think is what I need to put in your PlayerKit Player. There literally is no documentation that connects VimeoNetworking and Playerkit. Repeating this... there is literally no documentation on how to play a video from Vimeo in any of Vimeo's documentation. And when your documentation is out of date it makes it even more frustrating because I have no idea what any of these additional parameters are that are now in all of your functions that are necessary to set this up.
Here is the deal. I THINK that I need to get a video object and then use one of the files in the files array to put that into the player kit's set function. BUT I don't even know what files returns.. it always returns nil. Is it supposed to be a string? What is this? This isn't even the issue at the moment, just noting that your documentation says nothing about this.
I've tried authenticating via access token, I've tried authenticating using the "default client" in your example. I successfully authenticate, but I get nil when I try and access the files from the files object.
I tried looking at almost every single open and closed issue. The scope I have is set to public, private, and video files.
After I authenticate it says I am successfully authenticated.
When I try to print( account.user?.name) it prints out my username.
When I try to print( account.user?.membership) I get nil.
When I try to print(account.user?.accountType.rawValue) I get 0.
func getVimeoVideos(){
let vimeoClient = VimeoClient.defaultClient
//This doesn't work
let authenticationController = AuthenticationController(client: vimeoClient, appConfiguration: vimeoClient.configuration!, configureSessionManagerBlock: nil) // had to modify this because this is wrong in your documentation.
authenticationController.clientCredentialsGrant { result in
switch result {
case .success(let account):
print("Successfully authenticated with account: \(account)")
print( account.user?.name) // returns my username
print( account.user?.membership) //nil
print( account.user?.membership?.badge) //nil
print( account.user?.membership?.badge?.alt_text) //nil
print( account.user?.membership?.badge?.badgeType) //nil
print( account.user?.membership?.badge?.url) //nil
print( account.user?.membership?.badge?.text) //nil
print( account.accessToken) // returns a token
case .failure(let error):
print("error authenticating: \(error)")
}
}
// this doesn't work either - I just repeated the same code twice I comment out one or the other depending on how I want to choose to fail.
let authenticationController = AuthenticationController(client: vimeoClient, appConfiguration: vimeoClient.configuration!, configureSessionManagerBlock: nil)
authenticationController.accessToken(token: "********************") { result in
switch result
{
case .success(let account):
print("authenticated successfully: \(account)")
print( account.user?.name) // my username
print( account.user?.membership) //nil
print( account.user?.membership?.badge) //nil
print( account.user?.membership?.badge?.alt_text) //nil
print( account.user?.membership?.badge?.badgeType) //nil
print( account.user?.membership?.badge?.url) //nil
print( account.user?.membership?.badge?.text) //nil
print(account.isAuthenticatedWithClientCredentials()) //false
print(account.isAuthenticated()) //true
print(account.user?.accountType.rawValue) //0
case .failure(let error):
print("failure authenticating: \(error)")
}
}
let request = Request<[VIMVideo]>(path: "/channels/*******/videos")
let _ = vimeoClient.request(request) { [weak self] result in
guard let strongSelf = self else
{
return
}
switch result
{
case .success(let response): // had to update this because its wrong in your documentation needs to be lowercase
strongSelf.videos = response.model
if let nextPageRequest = response.nextPageRequest
{
print("starting next page request")
let _ = vimeoClient.request(nextPageRequest) { [weak self] result in
guard let strongSelf = self else
{
return
}
if case .success(let response) = result
{
print("next page request completed!")
strongSelf.videos.append(contentsOf: response.model)
print(strongSelf.videos)
//strongSelf.tableView.reloadData()
}
}
}
case .failure(let error):
let title = "Video Request Failed"
let message = "\(request.path) could not be loaded: \(error.localizedDescription)"
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(action)
strongSelf.present(alert, animated: true, completion: nil)
}
}
}
var videos: [VIMVideo] = []
{
didSet
{
print("Video count: \(videos.count)") // 1
if videos.count > 0 {
let firstVideo = videos[0]
print(firstVideo.files) // nil
print(firstVideo.files?.count) // nil
print(firstVideo.files?.first) // nil
if let videoLink = firstVideo.files?.first as? String {
print(videoLink)
self.player.set(AVURLAsset(url: URL(string: videoLink)!))
player.play()
}
/*
firstVideo.link
firstVideo.name
firstVideo.duration
firstVideo.videoDescription
firstVideo.uri
*/
}
}
}`
Any help would be greatly appreciated
@samgherman I am facing a similar issue, are you able to resolve it yourself?
I am facing the same issue now. But somehow I managed to extract the video URL using another third-party library called HCVimeoVideoExtractor. Maybe this provides a workaround to play videos on iOS natively.