public void openFile ( File file ) { final String path = massageFilePath ( file ) ; if ( path == null ) return ; inputFilePath = path ; // update recent items menu BoofSwingUtil . invokeNowOrLater ( ( ) -> { BoofSwingUtil . addToRecentFiles ( DemonstrationBase . this , path ) ; updateRecentItems ( ) ; } ) ; BufferedImage buffered = inputFilePath . endsWith ( "mjpeg" ) ? null : UtilImageIO . loadImage ( inputFilePath ) ; if ( buffered == null ) { if ( allowVideos ) openVideo ( false , inputFilePath ) ; } else if ( allowImages ) { openImage ( false , file . getName ( ) , buffered ) ; } }
Opens a file . First it will attempt to open it as an image . If that fails it will try opening it as a video . If all else fails tell the user it has failed . If a streaming source was running before it will be stopped .