Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
VLCKit
VLCKit
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 84
    • Issues 84
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VideoLAN
  • VLCKitVLCKit
  • Issues
  • #477

Closed
Open
Created Mar 03, 2021 by Andres Urdaneta@piscespieces

How to handle when string URL being passed to VLCMedia doesn't work?

I'm currently passing a stream url that doesn't work (or a random one). VLCKit would push the view and won't play anything (expected).

To handle that situation I'm implementing the following solution (which isn't beautiful but does the work for now)

mediaPlayer.media = VLCMedia(url: URL(string: mediaUrl)!)
        mediaPlayer.play()
        
        if (mediaPlayer.isPlaying == false) {
            DispatchQueue.main.asyncAfter(deadline: .now() + 4.0) {
                if (self.mediaPlayer.isPlaying == false) {
                    // do something
                    self.mediaPlayer.stop()
                }
                else {
                    print("placeholder")
                }
            }
        }

The about snippet translates to: After calling the .play() function, to the .isPlaying method returns false after 10 seconds, then do something

However, I'm obviously not sure about this solution. Is there any way that I can get an "error" to play with if the connection with the url that is being passed doesn't work (either because the connection times out or the string url isn't valid)?

Edited Mar 03, 2021 by Andres Urdaneta
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None