I am working on an app in which i have to display videos comes from JSON server some of them are youtube video and some are from other resources.
My problem is when i want to play video the videos which are from youtube link are playing perfectly but the other videos are not playing.
i imported <AVFoundation/AVFoundation.h>, <AVKit/AVKit.h>, MediaPlayer/MediaPlayer.h files also i imported YTPlayerView Files
I am using following code in UIWebView
[self.webvw setAllowsInlineMediaPlayback:YES];
[self.webvw setMediaPlaybackRequiresUserAction:NO];
NSString* embedHTML = [NSString stringWithFormat:#"%#",videoStr];
[self.webvw loadHTMLString:embedHTML baseURL:[[NSBundle mainBundle] resourceURL]];
The other video format is look like as:
"embed_code": "<object width="430" height="344"><embed width="430" height="344" type="application/x-shockwave-flash" wmode="transparent" src="http://xxxxxxx.xxxxxx/static/jscript/player/flowplayer/flowplayer.swf?config={'clip':{'baseUrl': 'http://myconnect.media/file/video/','url': '2017/02/3d045f0f240bfb73305f77c3da4d9218.flv','autoBuffering': true,'autoPlay': false}}"></embed></object>"
Related
I am using YTPlayerView for playing embedded videos in my app. Everything works perfect with ID but video doesn't play with URL. Here is my code
-(IBAction)playVideo:(id)sender{
self.playerView.delegate = self;
self.playerView.hidden = false;
[self.playerView loadVideoByURL:#"https://www.youtube.com/watch?v=KWTULSf29Ho" startSeconds:0 suggestedQuality:kYTPlaybackQualitySmall];
}
The URL has to be in the format youtube.com/v/VIDEO_ID?version=3, your url was wrong.
if you want to achieve the specific format, change your method which for responding user input url, appending ?version=3 with user input url.
check this,i think you forgot load the video into the player
I have this stream url with mp3 type: http://www.slobodnyvysielac.sk/redata/other/play.php?file=informacna%20vojna%20-%202015-02-17%20financne%20skupiny.mp3
when I open this url with Safari or Chrome, it can play, but I can't play it with objectives C code (iOS).
Please tell me the solution!
Thanks all!
player = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:#"http://archive.slobodnyvysielac.sk/informacna%20vojna%20-%202015-02-10%20hudo.mp3"]];
[player play];
Inside your view controller or whatever class you have define this, don't define it inside the event where you stream.
AVPlayer *player
EDIT:
There was a problem with your URL, if you open it in the browser, it opens a flash player so I inspected the flash object and got the original MP3 url which will stream, and you can compare how Google Chrome e.g. reacts to both URLs to notice the difference, now the url in my above code is the correct one
I have many url's like this:
https://www.youtube.com/watch?v=81_2Xb0XB_E&feature=youtube_gdata
I want to see in my app only the video, rather than a youtube page.
How can I go about this?
So far I have tried:
urlValue = [urlValue stringByReplacingOccurrencesOfString:#"watch?v="
withString:#"v/"];
urlValue = [urlValue stringByReplacingOccurrencesOfString:#"&feature"
withString:#"?version=3&f=playlists&app"];
This is the final url :
https://www.youtube.com/v/81_2Xb0XB_E?version=3&f=playlists&app=youtube_gdata_player
And this is how I load it:
NSString *videoHTML = [NSString stringWithFormat:#"<iframe type=\"text/html\" width=\"305\" height=\"180\" src=\"%#\" frameborder=\"0\"></iframe>", urlValue];
For some of them it's ok, I can watch it, but for others, like this url I cant watch. ("Watch this video on youtube . Playback on other website has been disabled by the video owner").
Any idea how can I improve my code? or if it's because of url?
Here is an example of url which is working:
http: //www.youtube.com/v/9M3wwddDec4?version=3&f=playlists&app=youtube_gdata_player
Give this a try HCYoutubeParser
In my app IOS I must play videos that reside on server. When I call the URL (http://www.example.com/example/?q=courses/9/module/148) from computer's browser it returns file (.flv) and the browser asked me if I have to save or open the file.
How to do to play video in IOS app'view by URL address?
Is it possible by UIWebView?
Thanks
First create an String with your html embed code, here is an example:
NSString *htmlString = [NSString stringWithFormat: #"<iframe src=\"http://myvideo.com" width=\"305\" height=\"150\" frameborder=\"0\" scrolling=\"no\"> </iframe>"];
Then load the address into your web view
[self.myWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString:#"http://whicheveraddresyouwant.com"]];
Does anyone know how to play a facebook video in a UIWebView?
My app uploads video to facebook and retrieves the video's url. I'd like to embed this url into a UIWebView to play back. I've worked this out for youtube but not Facebook. looking for help.
Orpheus!
I’m a few years late lol, but I’ll post the answer here anyway -- in Swift since it’s 2018 ;) -- just in case someone needs it.
You can use the following HTML string:
let embedCode = "<iframe src=\"https://www.facebook.com/plugins/video.php?href=\([INSERT VIDEO URL])&show_text=0&width=\(Int([INSERT WIDTH]))\" width=\"\(Int([INSERT WIDTH]))\" height=\"\(Int([INSERT WIDTH] * 56.25))\" style=\"border:none;overflow:hidden\" scrolling=\”no\" frameborder=\"0\" allowTransparency=\”true\" allowFullScreen=\"true\"></iframe>"
where you replace [INSERT VIDEO URL] with the video URL and [INSERT WIDTH] with the desired web view width.
Then load the HTML into the UIWebView like so:
webView.loadHTMLString(embedCode, baseURL: nil)