Why is movie jumpy when I play simultaneously in 2 Cocoa views? - cocoa

I have a Cocoa app that has two views. Both of these views are a subclass of QTMovieView. I want to play the same movie in both views (one view is a smaller preview of the larger view). Right now I'm doing:
QTMovie *movie = [[QTMovie alloc] initWithFile:path error:nil];
[largeView setMovie:movie];
[smallView setMovie:movie];
When I do this the movie is jumpy, it doesn't play smoothly. If I just set the movie to one or the other it seems to play just fine. I've tried multiple movies and they all do the same thing. Any ideas? Is there a better way to do this?

You are probably overtaxing a resource - CPU and/or disk I/O are your most likely culprits.
If you open two Quicktime windows can you play the movies at the same time without stuttering? Is your CPU maxed out (especially on a single-core machine)? Can you stream from a second source and fix the stuttering? You might try playing one of the movies off a USB hard drive or flash drive if you don't have two hard drives.
I'm not a quicktime or Objective-C programmer, but I'd start by looking at mirroring the content instead of opening two movie instances. Maybe you can capture a section of the screen, shrink the contents and dump it to a smaller preview window.

Related

Loading many images simultaneously causes Activity/Fragment to lag

I'm new to developping android TV applications. I am building a quizz game which needs a lot of images, videos, mp3 and gifs to show up simultaneously at a given time depending on the business logic of the game. I am using:
glide to show images / gifs (images are High Definition);
android Async and Handler / Thread / Runnable pattern to play sounds;
android video player to play videos (videos are High Definition);
nested RelativeLayout / LinearLayout to display the views;
View.setVisibility(GONE) to hide views and View.setVisibility(VISIBLE) to show it.
My problem is this:
On a Samsung galaxy tab 4 device, the game is smooth! But on a TV device, TCL 1920x1080 40dpi that should run the game, it is laggy.
I have read a lot of blog posts about how to optimize code ; like using ConstraintLayout instead of nested layouts, using View.setVisibility(INVISIBLE) instead of View.setVisibility(GONE) and I am also planning to use Picasso instead of Glide to get some fps but I'm not confident about all those. Can anyone give me advices on how to optimise my code to get some more fps (I mean getting like 10 or 15 fps not just 2 or 3)? Thanks in advance guys, cheer up!
in android manifest I added:
android:hardwareAccelerated="true"
solved the problem got 15fps higher.

HTML5 Fullscreen API & performance

I'm coding an app around video content and am currently playing around with HTML5's fullscreen API (I know it is still in very early stage).
Because of what my application does, the video itself isn't the only part that goes fullscreen: several elements alongside go fullscreen too, and I have noticed a great drop in performance there. The video streams ok, but other graphical elements suddenly get painfully slow. For example, a hover style typically takes about a good half second before showing up. A simple change in subtitles (I use popcorn.js) causes the video to freeze for a fraction of a second.
Any one knows why this is so? Do you experience the same? Thanks for your precious feedback.

Displaying AVPlayer content on two views simultaneously

I am creating an HTTP Live Streaming Client for Mac that will control video playback on a large screen. My goal is to have a control UI on the main screen, and full screen video on the secondary screen.
Using AVFoundation, I have successfully been able to open the stream and control all aspects of it from my control UI, and I am now attempting to duplicate the video on a secondary screen. This is proving more difficult than I imagined...
On the control screen, I have an AVPlayerLayer that is displaying the video content from an AVPlayer. My goal was to create another AVPlayerLayer, and send it the same player so that both players are playing the same video at the same time in two different views. However, that is not working.
Digging deeper, I found this in the AVFoundation docs:
You can create arbitrary numbers of player layers with the same AVPlayer object. Only the most-recently-created player layer will actually display the video content on-screen.
This is actually useless to me, because I need the video showing correctly in both views.
I can create a new instance of AVPlayerItem from the same AVAsset, then create a new AVPlayer and add it to a new AVPlayerLayer and have video show up, but they are no longer in sync because they are two different players generating two different audio streams playing different parts of the same stream.
Does anyone have any suggestions on how to get the same AVPlayer content into two different views? Perhaps some sort of CALayer mirroring trick?
AVSyncronizedLayer may help. I'm using it differently (to syncronize two different media objects rather than the same one) but in principle it should be possible to load the same item twice and then use an AvSyncronized layer to keep them synced.
I see that this topic got very old, but I think it still would be helpful. You wrote that
I have an AVPlayerLayer that is displaying the video content from an AVPlayer. My goal was to create another AVPlayerLayer, and send it the same player so that both players are playing the same video at the same time in two different views. However, that is not working.
But, it's working. I just tried it in my project. Here's my code of layer initializations:
AVPlayerLayer *playerLayer = [AVPlayerLayer new];
[playerLayer setPlayer:_testPlayer];
playerLayer.frame = CGRectMake(0, 0, _videoView.frame.size.width, _videoView.frame.size.height);
playerLayer.contentsGravity = kCAGravityResizeAspect;
playerLayer.videoGravity = AVLayerVideoGravityResizeAspect;
_defaultTransform = playerLayer.affineTransform;
[_videoView.layer insertSublayer:playerLayer atIndex:0];
AVPlayerLayer *testLayer_1 = [AVPlayerLayer playerLayerWithPlayer:_testPlayer];
testLayer_1.frame = CGRectMake(100, 100, 200, 200);
testLayer_1.contentsGravity = kCAGravityResizeAspect;
testLayer_1.videoGravity = AVLayerVideoGravityResizeAspect;
[_videoView.layer insertSublayer:testLayer_1 atIndex:1];
And here's what I got:
As you can see, there're two AVPlayerLayers playing the same AVPlayerItem in the very perfect sync
Apple's docs now state this:
You can create arbitrary numbers of player layers with the same AVPlayer object, but you should limit the number of layers you create to avoid impacting playback performance.
link to docs
This does indeed work in my app as well.

Auto-expand embedded Youtube video on play

How do I automatically expand an embedded youtube video when the user presses play?
The situation:
- For various reasons the ideal layout of the webpage mans that the video player must appear initially at a small size (let's say 480x385) when the user arrives on the page
- The video being shown contains some detail and is difficult to watch at 480x385
- Right now the user must click on the "full-screen" icon which comes standard in every youtube video player. This is irritating to many people.
The desired solution:
- When users click on the video to play it, the player automatically expands to a more reasonable size (e.g., 640x385 or 853x505) and plays at that size
- The video could be played in a modal overlay, but other solutions would be welcome as well
- Upon completion of the video, the expanded view should automatically disappear and the video should appear in it's original size on the page
You basically need two things:
The ability to detect when the the video is playing. You should be able to figure that out from this YouTube example.
Resize the player by changing the height and width properties of the "object" node that contains the player.

fast album art thumbnail handling like iTunes?

Im working with a few guys on trying to develop an app that requires some thumbnail scrubbing to handle album and tv show / movie art work in a grid view..
Much like iTunes does! But were having some trouble with getting the grid view to match the speed and agility of iTunes.
Anyone have suggestions on what to use in Cocoa UI world to make this better or more like iTunes?
See video for comparison...first our app then iTunes...
https://files.me.com/teemujin/0l0bc7.mov
IF you were to build an iTunes clone... how would you go about it?
Too many instances of view... switched to draw rect and reduced those instances till the redraw for scaling and scrolling was much improved.

Resources