I'm trying to play rtmp link in avplayer. However it's not playing. What should I do?
self.avAsset = AVAsset(URL: NSURL(string: rtmpUrlString)!)
Thanks.
AVPlayer doesn't support RTMP streaming.
The easiest way to play RTMP stream on iOS devices is play it via VLCKit
.
add pod 'MobileVLCKit-unstable', '3.0.0a23'
to your podfile.
run pod install
to install it.
add #import <MobileVLCKit/MobileVLCKit.h>
in your bridging header file to make this framework available in Swift
in your view controller initiate VLC Media Player and start playing stream:
var player: VLCMediaPlayer!
override func viewDidLoad() {
super.viewDidLoad()
player = VLCMediaPlayer()
player.media = VLCMedia(url: URL(string: "rtmp://сс.tv/sea")!)
player.drawable = view
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if !player.isPlaying {
player.play()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With