Skip to content

SwiftUI video player swift Example iOS for ios add video in the background Video from url SwiftUI swift player 비디오 플레이어 视频播放器 ビデオプレーヤー

Notifications You must be signed in to change notification settings

swiftuiux/swiftui-video-player-example

Repository files navigation

SwiftUI loop video player

The concept The concept

Settings

Name Description Default
SourceName The URL or local filename of the video. If a valid URL (http or https) is provided, the video will be streamed from the URL. If not a URL, the system will check if a video with the given name exists in the local bundle. The local name provided can either include an extension or be without one. The system first checks if the local name contains an extension. If the local name includes an extension, it extracts this extension and uses it as the default. If the local name does not contain an extension, the system assigns a default extension of .mp4 The default file extension can be set up via Ext param. -
Ext File extension for the video, used when loading from local resources. This is optional when a URL is provided and the URL ends with the video file extension. "mp4"
Gravity How the video content should be resized to fit the player's bounds. .resizeAspect
EColor Error message text color. .red
EFontSize Size of the error text. 17.0

Change video file dynamically

The concept

New Functionality: Remote Video URLs

Video Source Compatibility

Video Source Possible to Use Comments
YouTube No Violates YouTube's policy as it doesn't allow direct video streaming outside its platform.
Direct MP4 URLs Yes Directly accessible MP4 URLs can be used if they are hosted on servers that permit CORS.
HLS Streams Yes HLS streams are supported and can be used for live streaming purposes.

Disclaimer on Video Sources

Please note that using videos from URLs requires ensuring that you have the right to use and stream these videos. Videos hosted on platforms like YouTube cannot be used directly due to restrictions in their terms of service. Always ensure the video URL is compliant with copyright laws and platform policies.

![The concept](https://github.com/The-Igor/swiftui-loop-videoplayer-example/blob/main/swiftui-loop-videoplayer-example/img/remote_video_player_swiftui.gif)

Practical idea for the package

You can introduce video hints about some functionality into the app, for example how to add positions to favorites. Put loop video hint into background or open as popup.

The concept

The concept

Documentation(API)

  • You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)

  • Go to Product > Build Documentation or ⌃⇧⌘ D

XCode 15 beta note (iOS 17)

  • At the current time XCode 15 is in beta and in the console you might see message "A structure that defines how a layer displays a player’s visual content within the layer’s bounds" I found on Stack-overflow that many came across this message and at the time it is treated like XCode 15 beta bug

About

SwiftUI video player swift Example iOS for ios add video in the background Video from url SwiftUI swift player 비디오 플레이어 视频播放器 ビデオプレーヤー

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published