Important: Please read the Qt Code of Conduct -

Registering type based on AVFMediaPlayerSession

  • I'm not that experienced with this type of work, but I was wondering if it is possible to take avfmediaplayer out of the qtmultimedia module and make a separate type using qmlRegisterType. The reason is that I just need to add a small modification (DRM support) to the IOS part of the MediaPlayer.
    I managed to use AVPlayer to play the "video" (sound only, since no surface) like this:

    ViewRightKeyLoaderDelegate *loaderDelegate;
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
    loaderDelegate = [[ViewRightKeyLoaderDelegate alloc] init];
    [[asset resourceLoader] setDelegate:loaderDelegate queue:dispatch_get_main_queue()];
    playerItem = [[[AVPlayerItem alloc] initWithAsset:asset] autorelease] ;
    player = [[[AVPlayer alloc] initWithPlayerItem:playerItem] autorelease];
    AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
    playerViewController.player = player;
    [player play];

    And since AVFMediaPlayer is based on AVPlayer I figured it should work like this.

    So one option that I was thinking about is to make a separate type which would be the best solution (I guess), since it would be based on the MediaPlayer itself and hopefully just forwarding it to VideoOutput and have it displayed without having to create a new surface for it. I already tried this part, but end up with error: call to implicitly-deleted default constructor of 'QQmlElement<AVFMediaPlayerSession>', so hoping there is some way to fix this.

    Other option would be to build it from source with the added DRM support, but so far I don't fully understand how it's done (I did read the wiki about it, but need to do it few more times to understand).

    If anyone has any better ideas, I'm open for suggestions.

  • Lifetime Qt Champion


    It's a bit more complex than that due to integration with the GUI architecture.

    Building Qt from source for iOS is not that complex, see Building From Source for iOS.

  • Currently I'm trying to make the custom build from source. I saw the Qt Documentation, but I think it's not informative enough. There is no info on how to build just one module without the whole QT, and the IOS part, I'm using Xcode v9.2 and there is no Download option under preferences . I found how to build just one module, but I wonder if it will work, since DRM lib requires an additional step with a finalize script, in the time of writing I'm still doing the modification parts so I'll see if it works later.

    If that wont work, has anyone ever tried making a native IOS player component, or how can I make a surface for AVPlayer?

    EDIT: the modified build seems to work correctly so far

  • Lifetime Qt Champion

    Only one module is the same as any other Qt project: qmake, make -(jnumber_of_cores_) * (3 +1), make install.

    I'd recommend an out of source build so it's easier to manage.

Log in to reply