I've been looking at other posted questions regarding playing videos from websites and none of the solutions have worked for me. I get a black screen when I test my app, and the video doesn't seem to ever load.
Globally, I have declared:
var moviePlayer:MPMoviePlayerController!
And within my ViewDidLoad() function, I have:
let url:NSURL = NSURL(string:"http://uapi-f1.picovico.com/v2.1/v/nMirP/ArwenUndomiel.mp4")!
self.moviePlayer = MPMoviePlayerController(contentURL: url)
if let player = self.moviePlayer {
player.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
player.view.sizeToFit()
player.scalingMode = MPMovieScalingMode.None
player.movieSourceType = MPMovieSourceType.Streaming
self.view.addSubview(player.view)
player.play()
}
Thanks for the help!
The URL that Picovico have given you actually responds with a message telling the requester that the content is not at this location but that they should try a different location - this is a common technique for URL redirecting.
You can see this if you try the link in a browser and capture the network request and responses. For example using the link you include above in Chrome gives this response:
You can see that the server is telling the client (browser in this case) to redirect (i.e. send a new request) to an S3 amazon URL which is where your video actually has been stored by Picovico.
When the browser then sends it's request to that location it finds the video successfully:
Looking at your video using ffprobe the format seems fine so it seems likely that the iOS client is having a hard time handling the redirect, or else that there was an issues with the URL redirection temporarily on Picovico's servers. If you still have the problem now then the former is most likely the problem.
If you take a look here you can see how someone has solved the problem of iOS media player handling redirects:
iOS Mediaplayer and URL redirection
Related
I try to upload video to Facebook using Graph API.
But always see error message
(#100) No permission to publish the video.
Facebook app has Development mode. I created test user there. My role is admin. FB access token is valid.
Here my code here:
private func upload(url: URL) {
guard let data = try? Data(contentsOf: url) else { return }
let connection = GraphRequestConnection()
connection.delegate = self
var items: [String: Any] = [:]
items["title"] = "Test title from api"
items["\(url.absoluteString)"] = data
let keys = ["value" : "EVERYONE"]
items["privacy"] = keys
let request = GraphRequest(graphPath: "me/videos", parameters: items, httpMethod: .post)
connection.add(request) { reqconnection, anyInfo, error in
print(reqconnection)
print(anyInfo)
print(error)
}
connection.start()
}
I saw a lot of questions about it, but mostly they are too old and don't work for me.
Share video to FB
From thread FB Developers here - the same error, but they didn't find solution
Also check this docs - doesn't work
Also I'm a bit confused what docs are right for post video in Facebook.
Because in docs I see
The Video API allows you to publish Videos on Pages and Groups. Publishing on Users is not supported.
but also in another docs see Graph API with path me/videos. So it confused me a bit.
What docs are correct for my case:
here
here
From docs I see that
Your app should manage permissions as follows:
Graph API Requests - Before you send Graph API requests, you should check for necessary permissions and request them if needed.
Where can I find permission publish_actions?
Please help to figure out how to fix that.
I only can upload via ShareDialog. Like here and docs here
I know this has been answered in several related forms, but I have been twisting my brain for days trying to figure this out to no avail. I have tried every single solution I could find that seemed to be even remotely related.
I am using a WKWebView and loading the url of a website. On that website, a user will log in. In order to keep the user logged in, we need to maintain the session with a cookie. I have got this working perfectly on Android (using webview and cookies).
I need to figure the following out for iOS:
1) How to find cookie (if it already exists) and send it with the URLRequest.
2) How to make sure cookies are maintained between the app being opened and closed.
Ok, getting back to this months later :/
It was ridiculously simple. In the login page of the website I had embedded in the WKWebView, I was not clicking the 'remember me' checkbox. I went down a whole rabbit hole thinking that it had something to do with the cookie/s for the website never being saved, but I was never actually instructing it to do that.
Hope that helps anyone. My face is bruised from multiple facepalmings.
This Code Work For me -
Add this code in ViewDidLoad Method
let preferences = WKPreferences()
preferences.javaScriptEnabled = true
preferences.javaScriptCanOpenWindowsAutomatically = true
let wkUController = WKUserContentController()
let cookieScript = WKUserScript(source: "document.cookie = 'Set-Cookie: sessionId =\(Defaults[AppConstants.UD_SESSION_ID].string!)';", injectionTime: WKUserScriptInjectionTime.atDocumentStart, forMainFrameOnly: false)
wkUController.addUserScript(cookieScript)
let wkWebConfig = WKWebViewConfiguration()
wkWebConfig.userContentController = wkUController
wkWebConfig.preferences = preferences
// Adding webview
webView = WKWebView(frame: self.view.bounds, configuration: wkWebConfig)
var request = URLRequest(url: url)
request.addValue("Set-Cookie: sessionId = \(Defaults[AppConstants.UD_SESSION_ID].string!)", forHTTPHeaderField: "Cookie")
webView?.load(request)
im trying to play a protected video which you need to be logged thru our API and get a cookie to access to the m3u8. In Safari, i need to be logged in in order to play the video. I tried to implement this but doesnt work at all.
let cookies: [Any] = HTTPCookieStorage.shared.cookies!
self.playerAsset = AVURLAsset.init(url: urlStream!, options:[AVURLAssetHTTPCookiesKey : cookies])
let item = AVPlayerItem(asset: self.playerAsset!)
self.playerItems.append(item)
Anyone could help me ?
could you play the video in saffari? If yes then you can use the new safari webview instead of avplayer
I'm trying to update my app to work correctly with the new features of GameCenter in iOS10.
I create a new GKGameSession on device1, get a share URL, and all that works fine. I send the share URL out via a share sheet to device 2.
Device2 clicks the link, the device briefly displays 'Retrieving...' and then launches my app. Great! But, now what? Is there context information available for this URL that I can somehow access? Otherwise I have no way how to respond when the app is launched.
Previously you'd get a callback to something adhering to the GKLocalPlayerListener protocol, to the method player:didAcceptInvite:, and you could join the match that way. But with these iCloud-based messages, the player might not be even logged into GameCenter, right? This part seems to have been glossed over in the WWDC presentation.
Also, as of today (12/28/2016) there is no Apple documentation on these new methods.
Since the GKGameSessionEventListener callback session:didAddPlayer: only fires if the game is already running, to be sure you can process this callback every time requires a work around. I've tested this and it works.
When you send out an iMessage or email invite to the game, don't include the Game Session Invite URL directly in the message. Instead use a registered URL that will open your app when opened on a device on which your app is installed. Check here to see how:
Complete Tutorial on iOS Custom URL Schemes
But add a percent escaped encoding of the game invite URL as a parameter to this URL thusly (I'm assuming the registration of a url e.g. newGameRequest but it will be best to make this quite unique, or even better - though it requires more setup, try Universal Link Support as this will allow you to direct users who don't have your app installed to a webpage with a download link)
let openOverWordForPlayerChallenge = "newGameRequest://?token="
gameState.gameSession?.getShareURL { (url, error) in
guard error == nil else { return }
// No opponent so we need to issue an invite
let encodedChallengeURL = url!.absoluteString.addingPercentEncoding(withAllowedCharacters:.urlHostAllowed)
let nestedURLString = openOverWordForPlayerChallenge + encodedChallengeURL!
let nestedURL = URL(string: nestedURLString)!
}
send the URL in a message or email or WhatsApp or whatever. Then in your app delegate, add the following:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
var success = false
if let queryString = url.query {
if let urlStringToken = queryString.removingPercentEncoding {
let token = "token="
let startIndex = urlStringToken.startIndex
let stringRange = startIndex..<urlStringToken.index(startIndex, offsetBy: token.characters.count)
let urlString = urlStringToken.replacingOccurrences(of: token, with: "", options: .literal, range: stringRange)
if let url = URL(string: urlString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
success = true
}
}
}
}
return success
}
Now you can be sure the session:didAddPlayer: will be called. What's the betting this workarround is good for about 2 weeks, and they fix this in the next release of iOS showcased at WWDC 2017 ! Update: this problem hasn't been fixed - so the workaround above remains good!
I agree, the lack of documentation is frustrating. From what I can see, we have to:
add <GKGameSessionEventListener> protocol in the class' header
Then session:didAddPlayer: fires on the joining player's device after accepting an invite link.
update:
Unfortunately, I'm not surprised to hear your results. I hadn't tried all of those scenarios, but GKTurnBasedMatch had similar shortcomings. The way I got around it there was: I added a list of player statuses to match data (invited, active, quit, etc). I gave the player a view of "pending invitations." When they opened that view, I would load all of their matches and display the entries where the player was in invited state. With GKGameSession, that should work too.
Or, it might be easier if you could maintain a local list of sessions that you are aware of. Whenever the game becomes active, pull the entire list of sessions from the server and look for a new entry. The new entry would have to be the match the player just accepted by clicking the share URL.
I found this: https://github.com/VineAPI/VineAPI/blob/master/endpoints.md
I have following Some Process for share video on vine app.
1.Login:https://api.vineapp.com/users/authenticate
Authentication successfully using above doc lin API. I have received a key(session key).
for another Process.
After that use the next Api for Upload Video thumbnail On Vine.
2.thumnails
https://media.vineapp.com/upload/thumbs/1.3.1.mp4.jpg
Thumbnails successfully uploaded On vine and received the server response
get the uploaded thumbnails URL in X-Upload-Key. You can see the Above image.
3.Upload Video:https://media.vineapp.com/upload/videos/1.3.1.mp4
Video Data successfully uploaded On vine and received the server response
get the uploaded Video URL in X-Upload-Key. You can see the Above image.
4.Create Post:https://api.vineapp.com/posts
Post successfully create On vine and received the server response
{
code = "";
data = {
created = "2016-04-18T09:27:20.000000";
permalinkUrl = "https://vine.co/v/iFaqLt7w5Qm";
postId = 1333777877887795200;
videoUrl = "http://v.cdn.vine.co/static/private_post_old_client.mp4";
};
error = "";
success = 1;
}
When Open the permalinkUrl = "https://vine.co/v/iFaqLt7w5Qm"; get error message.You can see in Image
and aslo open link on browser
http://v.cdn.vine.co/static/private_post_old_client.mp4
Video autometically download but video did not download actual video.show some message On Video Like this.
Please Help me.Have you any Idea.
Finally I did it,
Just change the setting of AVAssetExportSession before exporting the video to save.
self.exportSession = [[AVAssetExportSession alloc] initWithAsset:mixComposition
presetName:AVAssetExportPreset640x480];
self.exportSession.outputFileType = AVFileTypeMPEG4;