DLGPlayer icon indicating copy to clipboard operation
DLGPlayer copied to clipboard

Playing local files

Open explaineverything opened this issue 6 years ago • 4 comments

I have a question. Does this player plays also local files (on iPad/iPhone) or only by http streaming? Thanks in response.

explaineverything avatar May 26 '18 17:05 explaineverything

Both local files and http streaming.

DeviLeo avatar May 28 '18 02:05 DeviLeo

Thanks. Maybe I am doing something wrong, but I cannot start playing video. I am running Example and in DLGPlayerViewController in viewDidLoad method I added:

    vc.autoplay = YES;
    vc.repeat = YES;
    vc.preventFromScreenLock = YES;
    vc.restorePlayAfterAppEnterForeground = YES;
    vc.view.frame = self.view.frame;
    [self.view addSubview:vc.view];

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"];
    NSLog(@"File exists: %@", @([NSFileManager.defaultManager fileExistsAtPath:filePath]));
    vc.url = filePath;
    [vc open];

    self.playerViewController = vc;

I have the following logs:

2018-05-28 10:32:46.495011+0200 DLGPlayer[5197:2841081] Metal GPU Frame Capture Enabled
2018-05-28 10:32:46.496260+0200 DLGPlayer[5197:2841081] Metal API Validation Enabled
2018-05-28 10:32:46.557246+0200 DLGPlayer[5197:2841081] File exists: 1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/containers/Bundle/Application/BDC1588E-6C46-4BC8-B7E6-338A0E536D5B/DLGPlayer.app/test.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2015-03-06T12:01:02.000000Z
  Duration: 00:00:15.00, bitrate: N/A
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), none, 1024x768, 119 kb/s, 30 fps, 30 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2015-03-06T12:01:02.000000Z
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 2 channels, 249 kb/s (default)
    Metadata:
      creation_time   : 2015-03-06T12:01:02.000000Z
      handler_name    : Core Media Audio
2018-05-28 10:33:00.003669+0200 DLGPlayer[5197:2841081] Status bar could not find cached time string image. Rendering in-process.

The video does not play, scrolling also doesn't work. Only black screen with empty bar is visible. Thanks for help.

explaineverything avatar May 28 '18 08:05 explaineverything

I suggest you open the media in viewDidAppear.
If you insist viewDidLoad, do the following changes in DLGPlayerViewController.m.

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initAll];
    [self registerNotification]; // <-- Move from viewWillAppear:
}

// Unregister notifications when dealloc
- (void)dealloc {
    [self unregisterNotification];  // <-- Move from viewWillDisappear:
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // [self registerNotification]; // <-- Delete
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    // [self unregisterNotification]; // <-- Delete
}

DeviLeo avatar May 28 '18 08:05 DeviLeo

Ok Thanks @DeviLeo!!! It works from viewDidApper: method.

explaineverything avatar May 28 '18 13:05 explaineverything