SwiftVideoBackground icon indicating copy to clipboard operation
SwiftVideoBackground copied to clipboard

cannot play video saved into phone storage

Open waleedmakarem opened this issue 5 years ago • 2 comments

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

waleedmakarem avatar Jan 07 '21 20:01 waleedmakarem

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

dingwilson avatar Jan 09 '21 06:01 dingwilson

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?

gromozekapp avatar Feb 28 '24 10:02 gromozekapp