Bug 902

Summary: GLMediaPlayer issue when using a File.toURI generated URI ( windows only )
Product: [JogAmp] Jogl Reporter: Maxime Caignart <maxime-jogamp>
Component: utilAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: ---    
Version: 2   
Hardware: All   
OS: windows   
Type: --- SCM Refs:
eb9225c928b9a1a5660c865921fcd91f85cd1cd0
Workaround: ---

Description Maxime Caignart 2013-11-11 18:54:59 CET
When using GLMediaPlayer.initStream(java.net.URI, int, int, int) method ( http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/av/GLMediaPlayer.html#initStream(java.net.URI, int, int, int) , if the URI targets a local file and has been generated by File.toURI ( http://docs.oracle.com/javase/7/docs/api/java/io/File.html#toURI()), GLMediaPlayer is not able to use the URI.

This happens only on Windows. An educated guess would be that the URI form "file://c:/mypath/mymovie.mp4" is not well handled by libav.

A workaround would be to rebuild the URI by hand, using the absolute path of the file :

------------------ NOT WORKING --------------
File movieFile = new File("res/mymovie.mp4");
URI uri = movieFile.toURI();
mediaPlayer.initStream(uri, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 3);


------------------ WORKING ------------------
File movieFile = new File("res/mymovie.mp4");
//IOUtil is from the package com.jogamp.common.util
String uriPath = IOUtil.encodeToURI(IOUtil.slashify(movieFile.getAbsolutePath(), false, false));
URI uri = new URI(uriPath);
mediaPlayer.initStream(uri, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 3);

This URI is still compliant with RFCs and well handled by libav under Windows.
Comment 1 Sven Gothel 2013-11-28 13:44:44 CET
eb9225c928b9a1a5660c865921fcd91f85cd1cd0
  FFMPEGMediaPlayer uses IOUtil.decodeURIIfFilePath(uri) to decode proper file-scheme if applicable - otherwise encoded ASCII URI.

See test case com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple
and it's '-file1' and '-file2' arguments.