简体   繁体   中英

Exoplayer equivalent for iOS - Video streaming similar to TikTok

Is there a exoplayer equivalent for iOS for playing videos?

Or could someone help me know how does TikTok stream videos? 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. Could someone help me or tell me how to get started?

The native player in iOS is 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. Streams for Android devices are typically DASH.mpd file streaming format.

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:

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 ):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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