Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:40:43+00:00 2026-06-10T12:40:43+00:00

I built my own custom video player (edit: find example code here ) with

  • 0

I built my own custom video player (edit: find example code here) with

AVMoviePlayerView.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@class AVPlayer;

@interface AVMoviePlayerView : UIView

@property (nonatomic) AVPlayer *player;

- (void)setPlayer:(AVPlayer*)player;
- (void)setVideoFillMode:(NSString *)fillMode;

@end

and

AVMoviePlayerView.m

#import "AVMoviePlayerView.h"
#import <CoreMedia/CoreMedia.h>

@implementation AVMoviePlayerView


+ (Class)layerClass {

    return [AVPlayerLayer class];

}

- (AVPlayer*)player
{
    return [(AVPlayerLayer*)[self layer] player];
}

- (void)setPlayer:(AVPlayer*)player
{
    [(AVPlayerLayer*)[self layer] setPlayer:player];
}

- (void)setVideoFillMode:(NSString *)fillMode
{
    AVPlayerLayer *playerLayer = (AVPlayerLayer*)[self layer];
    playerLayer.videoGravity = fillMode;
}


@end

calling it from inside my MainViewController.m within -(void)viewDidLoad

    NSURL* url = [[NSBundle mainBundle] URLForResource:@"myVideo.264" withExtension:@"mp4"]; 
    self.avPlayer = [AVPlayer playerWithURL:url];
    [avPlayer addObserver:self forKeyPath:@"status" options:0 context:AVMoviePlayerViewControllerStatusObservationContext];
    [[NSNotificationCenter defaultCenter]   addObserver:self
                                               selector:@selector(playerItemDidReachEnd:)
                                                   name:AVPlayerItemDidPlayToEndTimeNotification
                                                 object:[self.avPlayer currentItem]];

with methods

- (void)observeValueForKeyPath:(NSString*) path ofObject:(id)object change:(NSDictionary*)change context:(void*)context
{
    if (avPlayer.status == AVPlayerStatusReadyToPlay) {
        [self.VideoLoop setPlayer:self.avPlayer];
        [self.avPlayer play];
    }
}
- (void)playerItemDidReachEnd:(NSNotification *)notification {
    AVPlayerItem *p = [notification object];
    [p seekToTime:kCMTimeZero];
}

and of course defined in MainViewController.h

...
#import <CoreGraphics/CoreGraphics.h>
#import "AVMoviePlayerView.h"
@class AVMoviePlayerView;
@class AVPlayer;
...
IBOutlet AVMoviePlayerView *VideoLoop;
AVPlayer* avPlayer;

It works fine in Simulator (except the loop, but thats a different problem) but on the device (iPad3) no video shows up.

Did I miss anything?
Thanx!!!

EDIT: TO make it easier toshow me how stupid I am please find here some esample code. this does work in the simulator but not on device.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:40:45+00:00Added an answer on June 10, 2026 at 12:40 pm

    Reason found – costs me only 50 points…
    iOS supports MPEG-4 video up to 2.5 Mbps, and H.264 1080p. My video frame size was too big!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I developed my own custom web server for a robot I built ( video
I build my own widget with dojo as discussed here: Custom Widget Now, I
We have our own media player built in Javascript and I was wondering if
Update: I have provided complete code example in answer below. I have built my
n00b here (first Android project). I have been given a custom video codec that
I grabbed an example off of this SO question , and built my own
I've built a custom DLL which, for this example, has a function login .
I am not using a SearchManager, but I have built my own custom search
We had our own custom web server(written in java) built in 2005. We are
i built my own infinitescroll similar to the google image search. Everythings works fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.