Home > Software design >  how to catch error "moov atom not found" MobileVLCKit
how to catch error "moov atom not found" MobileVLCKit

Time:01-17

I want to catch the error

Moov atom not found

how can I do that?

I saw there is

VLCMediaPlayerError.moovAtomNotFound

But I get a message

Cannot find 'VLCMediaPlayerError' in scope

Thanks in advance for your help

CodePudding user response:

The error message "Moov atom not found" typically occurs when attempting to play a video file that has a problem with its moov atom. This atom is a crucial part of a video file's structure and contains important information about the video's layout, such as its duration, track information, and other metadata.

If you're using the VLC media player framework, you can try to catch this error by using the VLCMediaPlayerDelegate protocol's mediaPlayer:mediaPlaybackError: method. You would need to set the delegate of your VLCMediaPlayer instance to your class and implement the above method in it.

func mediaPlayer(_ aMediaPlayer: VLCMediaPlayer, mediaPlaybackError error: Error?) {
    if error?._code == VLCMediaPlayerError.moovAtomNotFound.rawValue {
        print("Moov atom not found")
    } else {
        // Handle other errors
    }
}

CodePudding user response:

It appears that the error you're trying to catch, "moov atom not found," is specific to the MobileVLCKit library, and it seems that the specific error enumeration you mentioned, "VLCMediaPlayerError.moovAtomNotFound," is not in scope or is not present in the version of MobileVLCKit that you are currently using.

You can try to catch the error by using a try-catch statement and checking for the error message.

Here's an example of how you can do that:

do {
    try mediaPlayer.play()
}catch {
    if error.localizedDescription == "moov atom not found" {
        // Handle the error here
    }
}

You can also check for the error code or status if provided by the library, or you can check for the error domain if it's provided by the library.

You also can check the documentation or the sample code of the library.

  • Related