Skip to content

Instantly share code, notes, and snippets.

View goodones-mac's full-sized avatar

Mac goodones-mac

View GitHub Profile
@goodones-mac
goodones-mac / VideoPlayerAlphaView.swift
Last active February 14, 2024 08:48
This lets you play a HEVC-with-alpha file on repeat and put it in as a SwiftUI view as a much smaller alternative to GIF files. This code is released into the public domain with no warranties, use as you like. Due to it being a SKView, not a UIView you can hypothetically use this within MacOS & iOS without many changes.
import AVFoundation
import SpriteKit
import SwiftUI
@MainActor
class TransparentBackgroundVideoPlayerUIView: SKView {
let backgroundNode: SKSpriteNode
let videoPlayer: AVPlayer
let videoNode: SKVideoNode
let url: URL