Fitness App Feature possible?

Hello everyone, I am learning Swift right now to develop a fitness app and I need to know, if what I have planned is practical/doable in SwiftUI:

One of the main features is supposed to be, that the user can pick short videos(max. 10sec) from their local photo/video gallery. Those videos can then be opened permanently from within the app. Now that doesn’t sound like something impossible to me… but I have never seen it done inside of a fitness app with videos, only with images. I am sure people have tried. What could be the catch?

-Timo

I am clueless but here is an idea.

Drag and drop the video into the assets folder in xcode. If xcode permits the drag and drop that is probably brcause xcode is just peachy with the file extension.

Then type Video(“filename”) in a view similar to Image(“imagename”) and see if xcode objects.

“Video” is probably not the correct object name syntax, but maybe you can figure out the equivalent of “Text” and “Image”.

Interesting question! Perhaps, this video about loading images from the user’s Photos app can also work with videos: CodeWithChris

This tutorial also goes over it, but seems to use UIKit: Swift UIImagePickerController. Wanna select an image or a video from… | by Myrick Chow | ITNEXT. Good thing is that it shows the user selecting videos.

You might also need core data/ another local database within the app to save the videos for later e.g. after closing your app.

It is not recommended to add videos into the Assets catalogue. The asset catalogue was never designed for that purpose. Videos should be added into the Bundle or better still should be stored on a remote server to avoid bloating the App.

It seems like the original poster wants to know how to display videos in an app that the user selects from his or her Photos library though. So somehow store a reference to the local video.

1 Like

Thank you very much RedFox1, I will look into it and hopefully find a way.

Hello Chris! As RedFox1 already mentioned, I am trying to carry out the whole thing locally, without a server 1) because of costs and 2) because I want this feature(watching the videos) to work offline. So I would create copies of the videos and load them into the bundle and then eventually the App would become bloated? Is the problem with that only the App taking up too much storage on the device? Or does it also become slow or something like that?

The videos can be saved to the Applications Document directory. That’s where any large data object should be saved. Much better than in the Assets catalogue.

How much video data are we talking about?

1 Like

15-100 short videos (max. 10 seconds per video), or up to 3GB, if they aren’t compressed.