cannot play video saved into phone storage
Dear sir, Thanks so much for the Ince library. Currently I am trying too play mp4 files that is saved into phone storage. I cannot run it. My code is :
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) let documentsDirectory = paths[0] print(documentsDirectory)
let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
let url = NSURL(fileURLWithPath: path)
if let pathComponent = url.appendingPathComponent("water.mp4") {
let filePath = pathComponent.path
let fileManager = FileManager.default
if fileManager.fileExists(atPath: filePath) {
print("FILE AVAILABLE")
let url = URL(string: filePath)!
videoBackground1.play(view: view1, url: url, darkness: 0.1)
} else {
print("FILE NOT AVAILABLE")
}
} else {
print("FILE PATH NOT AVAILABLE")
}
below is debug code:FILE AVAILABLE 2021-01-07 22:48:54.253683+0200 yarab[18271:807739] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600003c5d3e0> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2021-01-07 22:48:54.299434+0200 yarab[18271:807835] NSURLConnection finished with error - code -1002
Hey @waleedmakarem! Thanks for using SwiftVideoBackground! It looks like the url is unsupported. See:
https://developer.apple.com/documentation/foundation/1508628-url_loading_system_error_codes/nsurlerrorunsupportedurl
Thank you, everything works in 2024 both outside and inside:
try? VideoBackground.shared.play(view: view, videoName: "myVideo", videoType: "mp4")
/* or from URL */
guard let url = Bundle.main.url(forResource: "VFYD8043", withExtension: "mp4") else {return}
//let url = URL(string: "https://videos.pond5.com/holographic-background-purple-pink-blue-footage-182330759_main_xxl.mp4")
VideoBackground.shared.play(view: view, url: url)
but have message from Target Output:
2024-02-28 11:38:05.455243+0200 Lecture21-Cocoapods[2924:7394914] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600003fb8580> F8BB1C28-BAE8-11D6-9C31-00039315CD46
what it's mean?