gpt4 book ai didi

video - Exoplayer 等效于 iOS - 类似于 TikTok 的视频流

转载 作者:行者123 更新时间:2023-12-04 02:43:22 27 4
gpt4 key购买 nike

是否有适用于 iOS 的 exoplayer 播放视频?

或者有人可以帮我知道 TikTok 如何流式传输视频?它使用哪个视频播放器?我正在尝试从 firebase 数据库在我的应用程序中流式传输视频,我正在使用 Swift,但我坚持选择正确的方式来流式传输视频。有人可以帮助我或告诉我如何开始吗?

最佳答案

iOS 中的原生播放器是 AVPlayer

  • https://developer.apple.com/documentation/avfoundation/avplayer#//apple_ref/doc/uid/TP40009530

  • 与 Google 的 ExoPlayer 是 Android 中通常的默认设置一样(另请参阅@Manuel 在下面评论中的出色注释),AvPlayer 是 iOS 中的通常默认设置,您可以使用它来播放流视频,通常在 HLS 中适用于 Apple 设备的 .m3u8 文件流格式。 Android 设备的流通常是 DASH .mpd 文件流格式。

    目前,Apple 还为包括 iOS 在内的设备添加了一个新的 UI 框架 - 如果您正在使用它,那么值得寻找一些 AVPlayer 集成的好例子,例如:

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

    如果您使用的是更传统的 UIKit,那么 Apple 提供了一些您可以测试的简单示例,将您的测试代码替换为下面的代码(来自: https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos?language=objc):

    @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()
    }
    }

    关于video - Exoplayer 等效于 iOS - 类似于 TikTok 的视频流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58247765/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com