Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 54    Views: 121

Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
04/23/13 02:30 AM (11 years ago)

ATrains Video Plugin help

Hi guys, I am looking for a solution to something I would have thought others have thought about. When coding a native player normally, the video would rotate to landscape, even if the rest of the app didn't. As it is, the video player is little more than useless if it doesnt rotate. I can allow this to happen by sorting it in the app delegate but this allows the entire app to rotate which isnt appropriate. I've added snippets of code to the videocontroller.m to try and isolate the rotation to the player only but to no avail. I'd be really grateful if anyone else has looked at this major issue and has a solution, or maybe work through it with me? All the best.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 02:38 AM (11 years ago)
I haven't got this plugin but I have played around with video, I'm pretty sure that it is an option to have the screen rotate when full screen, if I can remember it doesn't rely on the view controller. Go into the .h file tell me what framework is sued to power the viseo player
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 02:41 AM (11 years ago)
MediaPlayer
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 02:54 AM (11 years ago)
I learned how to use that through mobiletuts, theat tutorila also didn't have full screen so I went to teh legendary stack overflow for assistance If you have a look at this it talks about the media controller and setting frames to full screen. http://stackoverflow.com/questions/8569358/mediaplayer-framework-ios-sdk
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 02:58 AM (11 years ago)
If you can't get your head around it drop me an email or a PM
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 03:12 AM (11 years ago)
Thanks!!
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/23/13 06:56 AM (11 years ago)
It's def by design that MediaPlayer launches in landscape. Who watches videos in Portrait mode? Good Stuff tho Kittsy. This link on one of those threads seems to have a good answer too you might find helpful: http://stackoverflow.com/questions/4911074/my-iphone-video-only-plays-in-portrait-mode?rq=1
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 07:10 AM (11 years ago)
Exactly! That's my issue, it launches in portrait and won't rotate when the device is turned..
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 07:15 AM (11 years ago)
I'll take a look when I get home, 10 plugins on the go I must procrastinate
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/23/13 07:50 AM (11 years ago)
My app has the same issue. I only want the MediaPlayer to rotate to landscape for watching videos and force all my other screens to remain in portrait mode. I've played with the 'BT_viewController.m' file but no real luck. I'll look over the links provided in this thread in the meantime but if someone finds a solution please share. Thx.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 08:19 AM (11 years ago)
Good luck! I don't seem able to override the app delegate in the media player.m I've got it building with no issues, simply won't rotate. I'm fairly certain the free video player on 1,5 did..
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 08:19 AM (11 years ago)
Thanks kittsy
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/23/13 09:33 AM (11 years ago)
In the interim I've had to allow all rotations and then try to customize each screen to look acceptable in landscape. However, some of the plugins just aren't written to be viewed in landscape. I seem to remember the BT v1.5 video player working in landscape as well but it may be a deeper issue in Xcode. I'll keep on trying as there must be a solution.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 10:20 AM (11 years ago)
I wonder if its possible to import the 1,5 version
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 10:20 AM (11 years ago)
I've figured out a solution hold the line just testing
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 10:42 AM (11 years ago)
Here we go, not gonna lie I'mpretty made up with this. We're going to use NSUser defaults In the yourApp_appDelegate.m add this line [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; directly under -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ then add this line [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; under around line 547 -(void)downloadAppData{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"downloadAppData%@", @""]]; Go to still in the appdelegate file it's about line 1220 //supportedInterfaceOrientationsForWindow... then swap if(canRotate){ for this if(canRotate | [[NSUserDefaults standardUserDefaults] boolForKey:@"allowMove"]){ that's it for the appDeleagate.m In At53_video_player.m At the end of this method -(IBAction)playMovie:(id)sender{ around line 129 add [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"allowMove"]; next find this - (void)movieEndedMethod:(NSNotification*)aNotification{ around line 171 add [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; That's it the mystery solved You can use this method for other screens just add the lines to view did appear [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"allowMove"]; and to return to normal create this method and put it before the dealloc at the bottom -(void)viewDidDisappear:(BOOL)animated{ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; }
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 10:48 AM (11 years ago)
Simply brilliant. I was just adding the iOS orientation code to no avail. I will give this a hit and let you know how I ho. Thanks greatly for spending the time in this!!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 10:51 AM (11 years ago)
To explain what I've done in a laymans version. NSUser defaults act like variables that aren't released from the app. You use the message to change the value in this version its a BOOL espression yes or no When the app loads we want to set it to say these custom rotations aren't on to start off with. This way it won't impact on the control panel rotations. The next if statement we ammended normally says if control panel says if we can rotate we rotate. We changed it to hey you can rotate if the control panel says so or you tell me with user default message that you can. In Atrains plugin we add the lines set no and set yes we set yes when the buttons pressed as we don't want the nice image layout to rotate. From this moment on the view can rotate to it's hearts content. We stop the rotations by sending the message in a method that says hey videos over. Hope that makes a little bit of sense
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 10:54 AM (11 years ago)
This was all mine as well stack overflow was no help today, but they don't have to deal with the one View controller, controlling everything. Welcome procrastination, it was a challenge and I love a challenge. I can see a lot of uses for this with other screens. Glad it helps, HOPE IT WORKS lol.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 10:56 AM (11 years ago)
AppDelgate.m I assume BOOL canRotate = TRUE; has superseded if(canRotate){ ? //supportedInterfaceOrientationsForWindow... -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"supportedInterfaceOrientationsForWindow %@", @""]]; //allow / dissallow rotations BOOL canRotate = TRUE; //appDelegate scootfest_appDelegate *appDelegate = (scootfest_appDelegate *)[[UIApplication sharedApplication] delegate]; if([appDelegate.rootApp.rootDevice isIPad]){ canRotate = TRUE; }else{ //should we prevent rotations on small devices? if([appDelegate.rootApp.jsonVars objectForKey:@"allowRotation"]){ if([[appDelegate.rootApp.jsonVars objectForKey:@"allowRotation"] isEqualToString:@"largeDevicesOnly"]){ NSLog(@"%@", @"SHOULD NOT ROTATE"); canRotate = FALSE; } } }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 10:58 AM (11 years ago)
It's the parts below your changing
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 10:59 AM (11 years ago)
This is the full method with teh change -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"supportedInterfaceOrientationsForWindow %@", @""]]; //allow / dissallow rotations BOOL canRotate = TRUE; //appDelegate matchgame_appDelegate *appDelegate = (matchgame_appDelegate *)[[UIApplication sharedApplication] delegate]; if([appDelegate.rootApp.rootDevice isIPad]){ canRotate = TRUE; }else{ //should we prevent rotations on small devices? if([appDelegate.rootApp.jsonVars objectForKey:@"allowRotation"]){ if([[appDelegate.rootApp.jsonVars objectForKey:@"allowRotation"] isEqualToString:@"largeDevicesOnly"]){ NSLog(@"%@", @"SHOULD NOT ROTATE"); canRotate = FALSE; } } } //bitwise OR operator... NSUInteger mask = 0; mask |= UIInterfaceOrientationMaskPortrait; if(canRotate | [[NSUserDefaults standardUserDefaults] boolForKey:@"allowMove"]){ mask |= UIInterfaceOrientationMaskLandscapeLeft; mask |= UIInterfaceOrientationMaskLandscapeRight; mask |= UIInterfaceOrientationMaskPortraitUpsideDown; } return mask; }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 11:02 AM (11 years ago)
It is the new 2.0 project your using mask |= UIInterfaceOrientationMaskPortrait; //This is the line you want to change if(canRotate | [[NSUserDefaults standardUserDefaults] boolForKey:@"allowMove"]){ mask |= UIInterfaceOrientationMaskLandscapeLeft; mask |= UIInterfaceOrientationMaskLandscapeRight; mask |= UIInterfaceOrientationMaskPortraitUpsideDown; }
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 11:03 AM (11 years ago)
I cant see any difference between them! Square eyes now i'm afraid!!
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 11:04 AM (11 years ago)
Sorry, yes!
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 11:04 AM (11 years ago)
Code blindness, long day - no beer in the house!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 11:04 AM (11 years ago)
I'm just waiting for Yes it works kittsys the man then I can go out for my tea
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 11:05 AM (11 years ago)
Code blindness, long day - no beer in the house!
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 11:12 AM (11 years ago)
Absolute LEGEND! I was way off with what I was trying to do! This is ground breaking for localizing this action, i'm sure it will be used and seen as a great break through. Thanks such a lot, it has turned a plugin of little use into a core part of my latest project so my gratitude cannot be underestimated! Have a nice tea!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 11:14 AM (11 years ago)
Cool. I just needed to look at it from different point of view. The appDelegate overrides everything so you can't change it you can remove functionality but no add it. I think I'm getting the hang off this coding malarky
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 11:15 AM (11 years ago)
I hope walee hasn't made all the changes to his files lol
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
04/23/13 11:22 AM (11 years ago)
Haha, he'll be annoyed if he has!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 11:29 AM (11 years ago)
Sorry I had a though how about if the app refreahed whilst watch in a video add this line [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; under -(void)downloadAppData{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"downloadAppData%@", @""]]; in the appdeleage.m file
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/24/13 11:20 AM (11 years ago)
Hey Kittsy and Alex@TM, Just got back to this thread and I've now implemented the code snippets and all works great! Thx for all the help. Take care.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/24/13 11:38 AM (11 years ago)
No probs enjoy
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/24/13 02:27 PM (11 years ago)
Hey Kittsy, FYI... I just got my first app into the iTunes store today and one of the plugins I used was your 'Buzz Carousel'. Great plugin and I'm sure it helped to get my app approved. My first update to the app will include the code you helped us with in this thread. Thx to you and all of the Buzztouch community for everything! Best regards.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/25/13 07:44 AM (11 years ago)
Wow. This is awesome. I just used NSUser defaults to store some toggle button states in a project and got an idea how useful they are. The only flaw I found is when you are developing you forget it overwrites them when you recompile and think it should stick. But a great idea to use them to manipulate/control the rotations. We really do need a per screen way to allow/disallow rotations and this looks like a possible answer. I can see why this won't work with the CP now - but I would have to think if David saw this trick he might look to make it a part of the core. Rotation is just becoming a bigger issue with more and larger devices. You would just need that standard code chunk to add at the start/end of your custom method. Android has SharedPreferences which work almost identically to NSUser - but device rotation is a whole different ballgame.... Folks should be all over this thread if they realize what you've done here. Can't wait to try this out later. Brilliant stuff Kittsy :)
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/25/13 08:17 AM (11 years ago)
Hey ATRAIN53, I second all your comments and agree that rotation has become an important function to be able to control based on each app's requirements. ------ On a side note, I'm using your 'AT53 Video Player' plugin and it works great for hosted or compiled video content but I can't get it to play YouTube content. The video screen just shows the spinning loader like it can't find the file. I've tried both the YouTube embedded and normal link formats with no luck. Any ideas?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/25/13 08:23 AM (11 years ago)
I'm working on some code obvthus model to control force landscape or portrait. Ilm post a neat tutorial
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/25/13 09:35 AM (11 years ago)
Sounds great Kittsy. Thx for the support.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/25/13 09:35 AM (11 years ago)
good news kittsy - pretty sad if this great discovery of yours gets burried and only a few folks see it. there mist be 10 posts a week asking about rotation and your solution looks boss. @WallE Youtube = Google We know how well Apple and Google want their stuff to work together right? They go to great lengths to make sure maps and videos work seamlessly on the devices. NOT This is the same company that pulled Google maps and tried to invent their own. Same company that removed the YT app from ios 6. I think they don't want and didn't design Mediaplayer framework to stream Youtube. They want that to be pushed thru a safari webview or you can try to launch native app custom url scheme for Youtube and hope the users have the YT app installed. If they don't it opens it in safari anyway.
 
WallE
Aspiring developer
Profile
Posts: 73
Reg: Jan 29, 2012
Burlington, Can...
2,880
like
04/25/13 09:49 AM (11 years ago)
Ya, love the Apple devices but not the politics! Keep on coding anyway. Take care.
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/27/13 05:54 PM (10 years ago)
Does this only rotate the this one screen? Do all screens have to rotate with this change? Jake
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/28/13 01:39 AM (10 years ago)
Yes but ou can use the code to make others rotate if you want to
 
trouty
I hate code!
Profile
Posts: 338
Reg: Mar 26, 2013
London Outskirt...
4,830
like
05/05/13 03:29 PM (10 years ago)
cool. added to my custom url screens :o) but i cant make it flip back when exiting added ths just above the dealloc -(void)viewDidDisappear:(BOOL)animated{ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; }
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
05/05/13 05:44 PM (10 years ago)
@trouty: I have the same problem, when you tap "back" it stays locked in landscape. Jake
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
05/27/13 12:07 AM (10 years ago)
Just found and implemented this- a thousand thanks Kittsy!
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
05/28/13 06:50 AM (10 years ago)
^ solid is this not @levens? BT really should adopt this. I don't think we'll see another technique to control the screen rotation so finitely. This is as good as it gets without some major code overhaul. This could be some of Kittsys finest work and he's got some masterpiece snippets out there. That BOOL value set via the Control Panel per screen would be the rotate per screen option everyone wants to see in BT. I see the occasional return to improper rotated screen as well - that viewDidDissappear method needs to fire at the proper time which can be tricky. Try moving the method around in code. Thanks again Kittsy, fabulous stuff :)
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/30/13 03:14 PM (10 years ago)
Hi Kittsy, First of all, thanks for sharing. But when you press "back" navigation, it seems like all my other screens is in landscape mode. How can I make this to auto rotate in portait? Regards, Cyrus
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
05/31/13 01:51 PM (10 years ago)
that's the problem unfortunately!!!
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
06/01/13 03:13 PM (10 years ago)
Hey guys, Any inputs, any ideas, directions are all welcome. Really needs some help to sort this out. Regards, Cyrus
 
LevensGardener
Aspiring developer
Profile
Posts: 220
Reg: Sep 30, 2012
Kendal
10,450
like
06/01/13 03:29 PM (10 years ago)
The fix worked perfectly for me. It adjusts to Landscape when needed, then reverts to portrait when the video finishes. There is a lot of discussion and other code thrown around above, but Kittsy's first code tweak was all that was needed. Geogious and Cyrus_8888 did you go further than in Kittsy's first description (04/23/13 06:42 PM) of the fix?
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
06/01/13 05:24 PM (10 years ago)
@ LevensGardener- well, I haven't try the code to use for video, but image gallery screens. Kittsy code works perfect. When I turn my device it rotates to landscape view, but when I tap "back" on the top navigation it locked the entire app display in landscape mode. @ trouty, @ Jake - I think we're on the same page. Have you dig out any solution?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
06/01/13 11:29 PM (10 years ago)
I didnt have this issue as my app is locked to portrait so it returns to portrait.
 
Djdios
Lost but trying
Profile
Posts: 175
Reg: Mar 20, 2013
Valby, Denmark
3,550
like
09/08/13 05:00 AM (10 years ago)
Did anybody come this any further?
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.