Play youtube video on iPhone by not pressing the default video icon - iphone

i want to know if it is possible to launch the youtube video without launching the default small photo icon. I just need a regular icon which is able to be launched to play a youtube video. Unfortunately, as the Youtube official suggestion suggests, there is currently no way to fulfill my request. Does any body concern this issue and already figure this out?
http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

if I understood your question correctly:
embed youtube player in a UIWebview and set the webview to hidden
in your customized button method do the following:
a- search for UIButton in the webview subviews :
-(UIButton*)getButtonInView:(UIView*)view{
UIButton *button = nil;
if([view isMemberOfClass:[UIButton class]]){
return (UIButton*) view;
}
if(view.subviews && [view.subviews count] > 0) {
for(UIView *subview in view.subviews) {
button=[self getButtonInView:subview];
if(button) return button;
}
}
return button;
}
b- send action to the fetched button:
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
hope that will help
----NOTE----
As mentioned by lxt. Please note that that this solution relies on Youtube plugin implementation not changing otherwise it might break in the future.

Related

Is it possible to Customize FaceBook PostView in iOS 6?

I'm using social framework to share with FaceBook. Is it possible to change the text on indicated buttons in the following screenshot?
Any help would be appreciated.
yes You can do it with bellow Method integration if you can send message using social framework to share with FaceBook.
you just need to add this :-
- (void)findSubViewofFB:(UIView*)theView
{
for (UIView * subview in theView.subviews)
{
// subview.hidden=TRUE;
if ([subview isKindOfClass:[UIButton class]])
{
UIButton *btn = (UIButton *)subview;
if([btn.titleLabel.text isEqualToString:#"Send"])
{
[btn setTitle:#"msg" forState:UIControlStateNormal];
}
}
[self findSubViewofFB:subview];
}
}
and add this above method in your message send class:-
[self findSubViewofTwitter:facebook.view];
i just tested it in my twitter integration of using social framework and change send Button Title as using above method and my Tweet message box look like:-

Embed youtube video and autoplay on iOS 6 don't work [duplicate]

This question already has answers here:
Can you autoplay HTML5 videos on the iPad?
(7 answers)
Closed 9 years ago.
I'm trying to embed youtube video and autoplay it on my app. The code is not working on iOS6, however it runs on older iOS 5 perfectly.
I do it in this way:
-(IBAction)playVideo:(id)sender {
myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
myWebView.delegate = self;
[myWebView setAllowsInlineMediaPlayback:YES];
myWebView.mediaPlaybackRequiresUserAction=NO;
[myWebView loadHTMLString:[NSString stringWithFormat:#"<embed id=\"yt\" src=\"%#\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"300\"></embed>", #"http://www.youtube.com/watch?v=TbsXUJITa40"] baseURL:nil];
}
- (UIButton *)findButtonInView:(UIView *)view {
UIButton *button = nil;
if ([view isMemberOfClass:[UIButton class]]) {
return (UIButton *)view;
}
if (view.subviews && [view.subviews count] > 0) {
for (UIView *subview in view.subviews) {
button = [self findButtonInView:subview];
if (button) return button;
}
}
return button;
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
UIButton *b = [self findButtonInView:webView];
[b sendActionsForControlEvents:UIControlEventTouchUpInside];
}
So- when the webview is loaded, it finds automatically the uibutton and the video starts. I can't understand, why in iOS 6 this method doesn't work anymore. It loads the video, but nothing appears...
Anyone can help me? I'm going crazy to try to solve it...
You need to use JS command. This link should help.
I hope it's not too late for an answer, but it plain simply is not possible in iOS. Like Apple states on it's documentation: https://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/AudioandVideoTagBasics/AudioandVideoTagBasics.html
To prevent unsolicited downloads over cellular networks at the user’s expense, embedded media cannot be played automatically in Safari on iOS—the user always initiates playback. A controller is automatically supplied on iPhone or iPod touch once playback in initiated, but for iPad you must either set the controls attribute or provide a controller using JavaScript.
Please pay attention that the documentation linked above is for Safari in general, not iOS-specific. To me, this was confusing on the first read until I noticed that.
So unfortunately no, for the moment this will not work on iOS.

exit fullscreen embeded youtube in webview

I am using embeded youtube in my webview for making a iPhone app. But I have couple of issues. First is, When I start playing video, it automatically goes to full screen. I want it to remain on the same frame while playing. Another issue is, I want it to run automatically. I mean I dont want to manually click run, I want, as soon as the app gets loaded, it should RUN AUTOMATICALLY without manually running, plus it should not run on FULLSCREEN.
Thanks
Akansha
I think you are loading embeded html string for youtube but it's not going to play automatically.
for that you need to put logic like bellow code
- (UIButton *)findButtonInView:(UIView *)view
{
UIButton *button = nil;
if ([view isMemberOfClass:[UIButton class]]) {
return (UIButton *)view;
}
if (view.subviews && [view.subviews count] > 0) {
for (UIView *subview in view.subviews) {
button = [self findButtonInView:subview];
if (button) return button;
}
}
return button;
}
- (void)webViewDidFinishLoad:(UIWebView *)theWebView
{
self.playButton = [self findButtonInView:theWebView];
[self.playButton sendActionsForControlEvents:UIControlEventTouchUpInside];
}
This will play video automatically as loading finished...

Adding "Breakpoint" or Pause in iPhone App

I have an app that is continuously taking in images from the video buffer (using the process described here: http://www.benjaminloulier.com/articles/ios4-and-direct-access-to-the-camera) and performing various processing on the most recent image in the buffer. For my particular application, when something noteworthy is found in the image, I want to display this information to the user and have the user decide whether the information is correct or not.
I want to display 2 UIButtons on the screen when this information is returned and it is at this point that I wish the code to "pause" (like a runtime breakpoint) and wait to see which button the user clicks before resuming. After clicking a button, the buttons will disappear.
The reason for this is I can't have the camera continue to acquire images and process them while I am waiting for the user input.
Thanks!
EDIT:
Here is what my code basically looks like:
if (continueRunningScript == YES) {
NSString *results = [self processImage];
[self displayResults: results];
// Show pause button
dispatch_async(dispatch_get_main_queue(), ^{
[pauseButton setHidden: NO];
});
}
and the pause button code:
- (UIAction) pauseButtonPress:(id) sender {
[pauseButton setHidden: YES];
[playButton setHidden: NO];
continueRunningScript = NO;
}
and the play button code:
- (UIAction) playButtonPress:(id) sender {
[playButton setHidden:YES];
continueRunningScript = YES;
}
Where could I add more boolean to handle the delay?

How can I start a YouTube video without the user touching the UIWebView itself?

We're developing an app which contains a TableView with some standard cells, but also a list of YouTube videos. We know how to embed the YouTube video data into a UIWebView and play it when the user touches it. But in order to do that, users must touch the UIWebView.
Since it's a TableView, every cell is the typical cell with the thumbnail on the left, some info and an accessory button on the right. We want to let users touch anywhere in the cell, not just the WebView (didSelectRow) so the video would start.
How can we achieve this?
We've thought of enabling a WebView at didSelectRow, embed the HTML data and show it fullscreen, but with this way users would need to touch once again into the play button to play the video, am I right?
Would it be possible to use MPMoviePlayerController instead, setting as the request URL the flv path of the video? (any api suggested?)
The last one would be simulating the touch inside the WebView so it would start the video, even if the user hasn't touched the UIWebView. Is it possible?
Any other suggestions?
Answering myself. I've found the solution. This code will autoplay the webview.
- (UIButton *)findButtonInView:(UIView *)view {
UIButton *button = nil;
if ([view isMemberOfClass:[UIButton class]]) {
return (UIButton *)view;
}
if (view.subviews && [view.subviews count] > 0) {
for (UIView *subview in view.subviews) {
button = [self findButtonInView:subview];
if (button) return button;
}
}
return button;
}
- (void)webViewDidFinishLoad:(UIWebView *)_webView {
UIButton *b = [self findButtonInView:_webView];
[b sendActionsForControlEvents:UIControlEventTouchUpInside];
}
Youtube video autoplay on iPhone's Safari or UIWebView
Hope it helps somebody else.