简体   繁体   English

相当于 iOS 的 Exoplayer - 类似于 TikTok 的视频流

[英]Exoplayer equivalent for iOS - Video streaming similar to TikTok

Is there a exoplayer equivalent for iOS for playing videos?是否有与 iOS 等效的 exoplayer 来播放视频?

Or could someone help me know how does TikTok stream videos?或者有人可以帮我知道 TikTok stream 视频如何? Which video player does it use?它使用哪个视频播放器? I'm trying to stream videos in my app from firebase database, I'm using Swift but am stuck in choosing the right way to stream the videos. I'm trying to stream videos in my app from firebase database, I'm using Swift but am stuck in choosing the right way to stream the videos. Could someone help me or tell me how to get started?有人可以帮助我或告诉我如何开始吗?

The native player in iOS is AVPlayer iOS中的原生播放器是AVPlayer

In the same way that Google's ExoPlayer is the usual default in Android (see @Manuel's excellent note in the comments below also), AvPlayer is the usual default in iOS and you can use it to play your streamed video, which will typically be in HLS.m3u8 file streaming format for Apple devices.与 Google 的 ExoPlayer 是 Android 中的常用默认设置相同(参见@Manuel 在下面评论中的出色注释),AvPlayer 是 iOS 中的常用默认设置,您可以使用它来播放流式视频,通常在 HLS 中适用于 Apple 设备的 .m3u8 文件流格式。 Streams for Android devices are typically DASH.mpd file streaming format. Android 设备的流通常是 DASH.mpd 文件流格式。

At this time Apple has also added in a new UI framework across devices including iOS - if you are using this it is worth searching for some good examples of AVPlayer integration, for example:此时,Apple 还添加了一个跨设备的新 UI 框架,包括 iOS - 如果您正在使用它,那么值得搜索一些 AVPlayer 集成的好例子,例如:

https://medium.com/@chris.mash/avplayer-swiftui-b87af6d0553 https://medium.com/@chris.mash/avplayer-swiftui-b87af6d0553

If you are using the more traditional UIKit then Apple provide some simple examples you can test with, substituting your test steam in the code below (from: https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos?language=objc ):如果您使用的是更传统的 UIKit,那么 Apple 会提供一些您可以测试的简单示例,将您的测试流替换为以下代码(来自: https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_video_editing/creating_and_a_vosic?对象):

@IBAction func playVideo(_ sender: UIButton) {
    //Substitute your video stream URL here to test
    guard let url = URL(string: "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8") else {
        return
    }
    // Create an AVPlayer, passing it the HTTP Live Streaming URL.
    let player = AVPlayer(url: url)

    // Create a new AVPlayerViewController and pass it a reference to the player.
    let controller = AVPlayerViewController()
    controller.player = player

    // Modally present the player and call the player's play() method when complete.
    present(controller, animated: true) {
        player.play()
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM