Skip to content

Selecting video file in Fragment #88

Open
@Mukhammadjon-Jalolov

Description

@Mukhammadjon-Jalolov

I am creating a Fragment in an app which displays this Fullscreen video view. The fragment has a button to open a device directory. Right after selecting a video file I'm creating a file from it in onActivityResult. But when I assign this File to fullscreen-video-view (inside onActivityResult) the app crashes after selecting a video

`override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

    if(requestCode == 55 && resultCode == Activity.RESULT_OK){
        val myinputstream = requireContext().contentResolver.openInputStream(data?.data!!)
        myVideoFile = File.createTempFile("vid", "vid")

        myinputstream.use { input ->
            myVideoFile.outputStream().use { output ->
                input!!.copyTo(output)
            }
        }
        fullscreenVideoView.videoFile(myVideoFile)  // myVideoFile is declared as **lateinit var myVideoFile: File**  
    }
}`

How to solve this issue? Where should I use fullscreenVideoView.videoFile(myVideoFile) after selecting a file... Thank you for help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions