All Projects → ChrisMash → AVPlayer-SwiftUI

ChrisMash / AVPlayer-SwiftUI

Licence: MIT license
Using AVPlayer in SwiftUI

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to AVPlayer-SwiftUI

Sjvideoplayer
iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer
Stars: ✭ 2,066 (+912.75%)
Mutual labels:  video-player, avplayer
Versaplayer
Versatile Video Player implementation for iOS, macOS, and tvOS
Stars: ✭ 608 (+198.04%)
Mutual labels:  video-player, avplayer
Vgplayer
📺 A simple iOS video player by Vein.
Stars: ✭ 383 (+87.75%)
Mutual labels:  video-player, avplayer
Avplayeroverlay
AVPlayer with custom controls, full screen mode, subtitles (.srt), Picture-In-Picture and AirPlay features.
Stars: ✭ 59 (-71.08%)
Mutual labels:  video-player, avplayer
Arplayer
Playback videos using ARKit and AVFoundation.
Stars: ✭ 117 (-42.65%)
Mutual labels:  video-player, avplayer
Abmediaview
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.
Stars: ✭ 79 (-61.27%)
Mutual labels:  video-player, avplayer
Kjplayerdemo
视频播放壳子:动态切换内核,支持边下边播边缓存的播放器方案,视频支持格式:mp4、m3u8、wav、avi,音频支持格式:midi、mp3
Stars: ✭ 60 (-70.59%)
Mutual labels:  video-player, avplayer
Bmplayer
A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.
Stars: ✭ 1,736 (+750.98%)
Mutual labels:  video-player, avplayer
UrbanVillageProjectScreens
Pretty iOS mobile screens + AVPlayer video view – made in SwiftUI
Stars: ✭ 23 (-88.73%)
Mutual labels:  avplayer, swiftui
ridesharing-ios
Ridesharing driver & rider sample apps using HyperTrack SDK
Stars: ✭ 97 (-52.45%)
Mutual labels:  swiftui
o-fish-ios
iOS app for the Officer's Fishery Information Sharing Hub (O-FISH). The mobile app allows fisheries officers to document and share critical information gathered during a routine vessel inspection.
Stars: ✭ 28 (-86.27%)
Mutual labels:  swiftui
paragon firewall ce
Paragon Firewall for Mac
Stars: ✭ 63 (-69.12%)
Mutual labels:  swiftui
Slipbox
The project is using Core Data with iCloud sync. It is a cross-platform app for iOS and macOS written in SwiftUI.
Stars: ✭ 49 (-75.98%)
Mutual labels:  swiftui
spiro
Swift Playgrounds 4 app created on the iPad
Stars: ✭ 48 (-76.47%)
Mutual labels:  swiftui
files videoplayer
📼 Old video viewer for Nextcloud
Stars: ✭ 92 (-54.9%)
Mutual labels:  video-player
MultiplatformPlayground
Kotlin Multiplatform project in Jetpack Compose & SwiftUI with shared ViewModel layer and File upload
Stars: ✭ 72 (-64.71%)
Mutual labels:  swiftui
SwiftDown
📦 A themable markdown editor component for your SwiftUI apps.
Stars: ✭ 203 (-0.49%)
Mutual labels:  swiftui
vimix
Live Video Mixer
Stars: ✭ 172 (-15.69%)
Mutual labels:  video-player
iOS-App
🕹️ iOS application of HardcoreTap game
Stars: ✭ 17 (-91.67%)
Mutual labels:  swiftui
SwiftUIDrag
A simple, customizable, and intuitive SwiftUI wrapper-view enabling dragging, floating, and/or collapsing for its content.
Stars: ✭ 42 (-79.41%)
Mutual labels:  swiftui

AVPlayer-SwiftUI

This repository is the result of my 4-part blog on using AVPlayer in SwiftUI:

Disclaimer: I'm no SwiftUI pro, there are things about this code that don't feel right but it works. And that's something 😁. I'll try and improve it over time! This code is also not battle tested, but seems to be ok!

The app starts off with a menu to select between a video player or an audio player. Parts 1-3 refer to the video player. Part 4 refers to the audio player.

Parts 1-3: Video Player Controls

The following diagram shows the view structs/classes in VideoView.swift:

(multiple structs/classes in a single file? Yep, I think it's easier to learn from with all these small structs/classes all in the same file, but maybe don't structure your own code this way)

alt text

The annotations show one of the first things that isn't quite right. VideoPlayerUIView doesn't actually care about the videoPos, videoDuration or seeking values, only VideoPlayerControlsView does. But at the time of writing part 3 of the blog series it was the only way I'd found to make it work.

Part 4: Better Observation of the Player

As mentioned above one of the issues I had at the end of Part 3 was that I was observing the player's time and duration in VideoPlayerUIView, which didn't actually care about those values. Since then I've found a better way to observe the values elsewhere, and in fact if it's only audio playing then the VideoPlayerUIView isn't required at all, so for that reason it's presented as just an audio player.

Part 4 also allows switching what the player is playing, which was a bit of a problem in the prior parts of the blog.

The following diagram shows the view structs/classes in AudioView.swift:

alt text

Part 5: VideoPlayer is here!

With the unveiling of iOS 14 at WWDC20 we now have VideoPlayer available as a View in SwiftUI! So that almost does away with the need for parts 1-4 in this series! Look how much simpler it is:

alt text

VideoPlayer is SwiftUI's answer to AVPlayerViewController, so if you're happy with the default controls you can drop it right in and get easy video playback with minimal effort.

If, on the other hand, you want some custom UI then parts 1-4 of this blog series will give you some clues as to how to achieve that.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].