Skip to content

yunihuang1112/HLS_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HLS_demo

A demo for playing M3U8 by AVPlayer in Swift.
Streaming demo for reading url from M3U8 string.

Check

If you want to access http(without s) url,
make sure you have set "App Transport Security Settings" and "Allow Arbitrary Loads" to "YES".

What we do?

Here we set M3U8 url to AVPlayer.
Use play() / pause() to set player.
AVPlayer does not have "stop", just to pause it and set it to nil.

Get duration for video

We get total duration by

videoPlayer.currentItem?.asset.duration  

And get current playing time by

videoPlayer?.addPeriodicTimeObserver(forInterval: CMTime(seconds: Double(1), preferredTimescale: 2), queue: DispatchQueue.main), using: {})

About

A demo for playing M3U8 by AVPlayer in Swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages