Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Video Player

 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to play a video that is packaged with the jar file?
How can it be done?
 
Ed Schepis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do it using the Class.getResourceAsStream method. It gets a resource (audio, video,...) from jar file.
Then you can use the InputStream for the Player.

For instance:
InputStream is = getClass().getResourceAsStream("myvideo.mpg");
Player player = Manager.createPlayer( is, "video/mpg" );

For some examples take a look at TechDays from Sun:
http://developers.sun.com/events/techdays/presentations/hyderabad/MIDP2.0-DevWirelessApps-Hyderabad.pdf

and at forum.nokia.com:
http://www.forum.nokia.com/main/1,6566,21,00.html?fsrParam=1-3-/main/1,6566,21_10,00.html&fileID=2777

Ed
 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That didn't work.
I got this error:
Media Exception error: Cannot create a Player for: video/mpg
 
Ed Schepis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on the device you are using. Not all the devices implement mpeg format (i.e. Nokia use 3gp format).
But in emulator must work with mpeg.
 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using an emulator, WTK22 beta version and it doesn't work
 
Ed Schepis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... sorry that's my fault... use "video/mpeg" content type instead of "video/mpg"... that was a typo.
 
Ian Strain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried that already too but still no joy
 
Ed Schepis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want post some snippet of your code?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic