samedi 18 juin 2016

Stream Foxnews/AbcNews swf video on iPhone's UIWebView


I want to run a video from foxnews/abcnews in my news app. I have tried using UIWebView, SafariView and even launching it in safari, but it doesn't run. You can however run the url on your iphone safari browser easily (try copy pasting url from below). I have tried embedding the url in html and also using iframe.

Here is my code

let foxNewsUrl:String! = "https://video.foxnews.com/assets/video-player.swf?video_id=4921342359001&d=video.foxnews.com&auto_play=true"
let abcNewsUrl:String! = "https://abcnewsplayer-a.akamaihd.net/player/2.19.0.0004/amp.premier/AkamaiPremierPlayer.swf?settings_url=https://abcnewsplayer-a.akamaihd.net/player/2.19.0.0004/amp.premier/amp.premier.flashonly.xml?sec=1&params=%7B%22playerId%22%3A%22facebookHTTPS%22%7D&data_feed_url=http://abcnews.go.com/video/itemfeed?id=39515399&auto_play=true&ad_control_enabled=false"

let embedHTML:String! = "<html><head></head><body style="margin:0"> <embed id="yt" src="(foxNewsUrl)" type="application/x-shockwave-flash" width="100%" height="100%"></embed></body></html>";

let nsurl = NSURL( string: abcnewHtml)
let request = NSURLRequest(URL: nsurl!)

let myWebView:UIWebView = UIWebView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height))

// loadRequest in UIWebView:
myWebView.loadRequest(request)

// load embed html in UIWebView
myWebView.loadHTMLString(embedHTML!, baseURL: nil)
self.view.addSubview(myWebView)

// launch SafariViewController
let htmlUrl3 = NSURL( string: abcNewsUrl)
let svc = SFSafariViewController(URL: htmlUrl3!)
self.presentViewController(svc, animated: false, completion: nil)

// launch Safari outside of the app: this also doesn't work, 
// it opens a 'Safari cannot download this file' dialog.
UIApplication.sharedApplication().openURL(NSURL(string: foxNewsUrl!)!)

None of these are working. Please help. Any help will be deeply appreciated.


Aucun commentaire:

Enregistrer un commentaire