Bug 902 - GLMediaPlayer issue when using a File.toURI generated URI ( windows only )
Summary: GLMediaPlayer issue when using a File.toURI generated URI ( windows only )
Alias: None
Product: Jogl
Classification: JogAmp
Component: util (show other bugs)
Version: 2
Hardware: All windows
: --- normal
Assignee: Sven Gothel
Depends on:
Reported: 2013-11-11 18:54 CET by Maxime Caignart
Modified: 2013-11-28 13:44 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
Workaround: ---


Note You need to log in before you can comment on or make changes to this bug.
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
  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.