How to play video with AVPlayer FairPlay DRM m3u8 ios swift

986 Views Asked by At

This is My json :

  "playinfoid": {
         "sd": "0242EEEC-1EF0-0E05-E13A-2BAF4136EFC9",
         "hd": "0242EEEC-1EF0-0E05-E13A-2BAF4136EFC9",
         "uhd": null
      },
      "playinfo": {
         "tokenurl": null,
         "url": null
      },
      "id": "LEGOMARVELSW0178383",
      "zonesinfo": {
         "duration": 1269,
         "endcreditsautocompleted": false,
         "previouslytcin": null,
         "previouslytcout": null,
         "startcreditstcin": null,
         "startcreditstcout": null,
         "endcreditstcin": 1239,
         "endcreditstcout": 1269
      }

this is an exemple of url that i should have the same format : https://bitmovin-a.akamaihd.net/content/bbb/stream.m3u8

My question is how can i from my json get url like that to can i use it in AVPlayer

1

There are 1 best solutions below

0
Mick On

The link you shared is to a HLS video - i.e. a video which is streamed using the HLS streaming protocol.

If this is the format you want you will need to prepare your video for HLS streaming - this involves segmenting it and possibly transcoding it if you want to support multiple bit rates, which is typical with HLS and one of the key reasons it gets used.

There are multiple free and paid tools, servers and services which you can use to do this - e.g. one example using FFmpeg: https://gist.github.com/lukebussey/4d27678c72580aeb660c19a6fb73e9ee

As an aside, the linked file you shared doe snot appear to be DRM protected so you do not need any FairPlay key to play to back.