SlideShare a Scribd company logo
10
Most read
15
Most read
21
Most read
JAVA MEDIA FRAMEWORK
Ms. Vishwakarma Payal Rambali Shailkumari
M.Sc.-II (Computer Science)
Roll No: 05
Outline
 What is Java Media Framework?
 Creating Media Player .
 Prefetching the Media .
 Adding the Player to your Application .
 Registering the Applet as a Listener .
 Starting the Player .
 Cleaning up and Stopping the Player .
 The States of the Player .
 Adding Controls to the Player .
 Setting the Media Time and Changing Rate .
 Features of JMF .
What is Java Media Framework ?
 The java media framework provides the means to present all
kinds of interesting media type.
 The java media framework is an API for integrating
advanced media formats into java, such as video and
sound.
 The media framework has several components, including
media players, media capture, and conferencing .
 A key to any of these topics is in providing a timing
mechanism, which determines when the next part of the
media should be played. It is important to have a
mechanism to keep a video stream playing at the same
speed as accompanying sound stream.
Creating a Media Player
 By creating an applet that uses a media player. Putting the
media into applet involve a few basic steps:
1. Create the URL for media file.
2. Create the player for the media.
3. Tell the player to prefetch .
4. Add the player to the applet.
5. Start the player.
Creating a Media Player
 To create the player you utilize the Manager class. The
Manager class is actually the hub for getting both the
timebase and the players.
 The first task is to create an URL for file then to create the
player.
 Example : In the BasicPlayer class, following are happens in
the init() method.
Creating a Player and it’s
associated URL
try
{
mediaURL =new URL(getDocumentBase(),mediafile);
Player=Manager.createPlayer(mediaURL);
}
catch(IOException e)
{
System.out.println(“URL for “+ mediafile” is invalid);
}
Prefetching the Media
 Prefetching causes two things:
1. The player goes through a process called realization.
2. It then starts to download the media file so that some of it
can be cached.
 This reduces the latency time before the player can start
actually playing the media.
 Example : In the BasicPlayer class, following are happens in
the start() method.
 In the start method ,we prefetch the media we are going to
play.
Example:
public void start()
{
if(player!=null)
{
//prefetch starts the player .
player.prefetch();
}
}
Prefetching the Media
Adding Player to your Application
 Adding the player to application is actually kind of tricky .
 The player itself is not an AWT component. So you don’t add
the player it self ,but it’s visual representation.
 To get the visual component ,player has a method called
getVisualComponent().
 Player has a method called getState() that returns the state of
the current player .
 ControllerListener has one method-
ControllerUpdate(ControllerEvent).
 We can use the ControllerUpdate method to know when the
media has been fetched.
 ControllerUpdate() method is called each time the state of the
controller changes.
Example:
Adding Player to your Application
public synchronized void control update(ControllerEvent event)
{
if(event instanceof RealizeCompleteEvent)
{
if((VisualComponent = player.getVisualCompent())!=null)
add(“center”,visualComponent);
validate();
}
}
Registering the Applet
as a Listener
 To have the player call ControllerUpdate() you must first
register your application with the player.
 Just like all java.awt.event listener after a component has
been registered as listener ,it’s the method will be call any
time an event occurs.
 For the current purposes you will add the
addControllerListener code to the init() method of the applet.
Public void init()
{
String mediaFile =null;
URL mediaURL=null;
setLayout(new BorderLayout());
If((mediaFile=getParameter(“file”))==null)
{
System.err.print(“Media file not present”);
System.err.print(“Required parameter is ‘file’ ”);
}
else
{
try
{
mediaURL = new URL(getDocumentBase(),mediafile);
player=manager.createPlayer(mediaURL);
}
}
Registering the Applet
as a Listener
Starting the Player
 start() which tells player to start. The more fundamental
methods allows to start the player and specify when it will
actually display it’s media.
 The syncstart() method is the method that actually causes
the player to start.
Example :
If(event instanceof PrefetchCompleteEvent)
{
player.start();
}
Cleaning Up and Stopping the
Player
 stop() method must be used to stop the media player and
clean up.
 The stop() method is called when browser leaves the current
web pages. After browser leaves the page, we should stop
playing the current media.
 One addition step we should take-removing the media from
memory. The player has deallocate() method. As soon as you
know that you no longer need a media ,you should tell the
player to deallocate it so that it can be garbage collected.
 Using both the player’s stop() and deallcoate() methods, you
can create the applets stop method.
Example:
Public void stop()
{
if(player!=null)
{
player.deallocate();
}
}
Cleaning Up and Stopping the
Player
States of the Players
 There are different states that player goes through during
normal operation.
Unrealized
realize()
Realizing
Realized
Prefetch()
Prefetching
Prefetch
Start()/deallocate()
Start
deallocate()
 Unrealized: At this stage, the player does not know anything
about the media except what the URL to the media is.
 Realizing: In the realizing state, the player acquired all of
resources that are non-exclusive.
 Realized: When the player enters the realized state, the
RealizeCompleteEvent is issued.
 Prefetching: To get the player to move into the prefetching
state, you can use the prefetch() method.
States of the Players
 Prefetched :Entering the prefetched state, a player issues the
PrefetchCompleteEvent.
 Started : When player is started, it enters the started state.
States of the Players
Adding Controls to the Players
Example:
Public synchronized void controllerUpdate(ControllerEvent event)
{
if(event isnstaceofRealizeCompleteEvent)
{
if((visualComponent =player.getVisualComponent())!=null)
if(visualComponent!=null)
add(“South”,controlComponent);
else
add(“Center”,controlComponent);
}}
 Each type of the player has the capability to give you a set of
controls using the ControlPanelComponent() method.
 Like the getVisualComponent() method, the
getControlPanelComponent() cannot be used until after the
player has been realized.
Setting the media time and
Changing rate
 The setMediaTime() method takes long parameter and that
number represents the time in nanoseconds.
 The setRate() method returns to you the actual rate that has
been applied.
Example :
if(event isnstaceofPrefetchCompleteEvent)
{
System.out.println(“Prefetching : ” + newDate());
player.setRate((float)2.0);
player.start();
}
Features of JMF
 JMF supports many popular media formats such as JPEG,
MPEG-1, MPEG-2, QuickTime, AVI, WAV, MP3, GSM, G723,
H263, and MIDI.
 JMF supports popular media access protocols such as file,
HTTP, HTTPS, FTP, RTP, and RTSP.
 JMF uses a well-defined event reporting mechanism that follows
the “Observer” design pattern. JMF uses the “Factory” design
pattern that simplifies the creation of JMF objects.
 The JMF support the reception and transmission of media
streams using Real-time Transport Protocol (RTP) and JMF
supports management of RTP sessions.
References
 Book:
Advanced JAVA
 Websites:
 http://www.programming.com/GepBook/Chapter7/M3L1.p
pt
 https://web.cs.dal.ca/~mheywood/CSCI6506/HandOuts/N
04-Deception.pdf
Thank you . . .!!!!!

More Related Content

PPSX
JDBC: java DataBase connectivity
PPTX
Design techniques
PPTX
Kernel module in linux os.
PPTX
Event handling
PPTX
JAVA AWT
PPTX
Attributes of output primitives( curve attributes & area fill attributes)
PPTX
Water jug problem ai part 6
PPT
Servlet life cycle
JDBC: java DataBase connectivity
Design techniques
Kernel module in linux os.
Event handling
JAVA AWT
Attributes of output primitives( curve attributes & area fill attributes)
Water jug problem ai part 6
Servlet life cycle

What's hot (20)

PPT
PPT
Java layoutmanager
PPTX
File system structure
PPTX
System calls
PPTX
Semantic net in AI
PPTX
Heap Management
PPTX
Java servlets
PPTX
Multimedia operating system
PPTX
Mathematical Analysis of Non-Recursive Algorithm.
PPTX
Specification-of-tokens
PPT
File models and file accessing models
PDF
CS9222 ADVANCED OPERATING SYSTEMS
PPTX
Concurrency control
PPT
Os Swapping, Paging, Segmentation and Virtual Memory
PPTX
knowledge representation using rules
PPT
Communication primitives
PPT
RichControl in Asp.net
PDF
Java threads
ODP
Distributed operating system(os)
PDF
CS9222 Advanced Operating System
Java layoutmanager
File system structure
System calls
Semantic net in AI
Heap Management
Java servlets
Multimedia operating system
Mathematical Analysis of Non-Recursive Algorithm.
Specification-of-tokens
File models and file accessing models
CS9222 ADVANCED OPERATING SYSTEMS
Concurrency control
Os Swapping, Paging, Segmentation and Virtual Memory
knowledge representation using rules
Communication primitives
RichControl in Asp.net
Java threads
Distributed operating system(os)
CS9222 Advanced Operating System
Ad

Similar to Java media framework (20)

PPTX
Designing of media player
PDF
mjar
PPTX
Project on mp4 Media Player using JavaFx
PPTX
Presentation final
PPT
Java Media Framework API
PPTX
java Unit4 chapter1 applets
PDF
Lecture 22
PPT
Scmad Chapter12
KEY
Standardize Your Flash with Adobe OSMF (0.9)
PPT
Java Media Player thorugh JMF
PPTX
Android Multimedia Player Project Presentation
PPT
Dense And Hot 360 Flex
PPT
Dense And Hot Web Du
PPT
Jsr135 sup
PPT
Basic java part_ii
PDF
Adobe OSMF Overview
PDF
Android media framework overview
PPTX
L18 applets
PDF
AWT Enhancements in V1.1 - Supporting Richer GUI Development
PPTX
Loading viewing/listening to Image and Audio, Fonts, Colors in Java
Designing of media player
mjar
Project on mp4 Media Player using JavaFx
Presentation final
Java Media Framework API
java Unit4 chapter1 applets
Lecture 22
Scmad Chapter12
Standardize Your Flash with Adobe OSMF (0.9)
Java Media Player thorugh JMF
Android Multimedia Player Project Presentation
Dense And Hot 360 Flex
Dense And Hot Web Du
Jsr135 sup
Basic java part_ii
Adobe OSMF Overview
Android media framework overview
L18 applets
AWT Enhancements in V1.1 - Supporting Richer GUI Development
Loading viewing/listening to Image and Audio, Fonts, Colors in Java
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPT
Teaching material agriculture food technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Cloud computing and distributed systems.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
sap open course for s4hana steps from ECC to s4
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25-Week II
Digital-Transformation-Roadmap-for-Companies.pptx
Machine Learning_overview_presentation.pptx
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Teaching material agriculture food technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Cloud computing and distributed systems.
Programs and apps: productivity, graphics, security and other tools
Assigned Numbers - 2025 - Bluetooth® Document
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
sap open course for s4hana steps from ECC to s4
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

Java media framework

  • 1. JAVA MEDIA FRAMEWORK Ms. Vishwakarma Payal Rambali Shailkumari M.Sc.-II (Computer Science) Roll No: 05
  • 2. Outline  What is Java Media Framework?  Creating Media Player .  Prefetching the Media .  Adding the Player to your Application .  Registering the Applet as a Listener .  Starting the Player .  Cleaning up and Stopping the Player .  The States of the Player .  Adding Controls to the Player .  Setting the Media Time and Changing Rate .  Features of JMF .
  • 3. What is Java Media Framework ?  The java media framework provides the means to present all kinds of interesting media type.  The java media framework is an API for integrating advanced media formats into java, such as video and sound.  The media framework has several components, including media players, media capture, and conferencing .  A key to any of these topics is in providing a timing mechanism, which determines when the next part of the media should be played. It is important to have a mechanism to keep a video stream playing at the same speed as accompanying sound stream.
  • 4. Creating a Media Player  By creating an applet that uses a media player. Putting the media into applet involve a few basic steps: 1. Create the URL for media file. 2. Create the player for the media. 3. Tell the player to prefetch . 4. Add the player to the applet. 5. Start the player.
  • 5. Creating a Media Player  To create the player you utilize the Manager class. The Manager class is actually the hub for getting both the timebase and the players.  The first task is to create an URL for file then to create the player.  Example : In the BasicPlayer class, following are happens in the init() method.
  • 6. Creating a Player and it’s associated URL try { mediaURL =new URL(getDocumentBase(),mediafile); Player=Manager.createPlayer(mediaURL); } catch(IOException e) { System.out.println(“URL for “+ mediafile” is invalid); }
  • 7. Prefetching the Media  Prefetching causes two things: 1. The player goes through a process called realization. 2. It then starts to download the media file so that some of it can be cached.  This reduces the latency time before the player can start actually playing the media.  Example : In the BasicPlayer class, following are happens in the start() method.
  • 8.  In the start method ,we prefetch the media we are going to play. Example: public void start() { if(player!=null) { //prefetch starts the player . player.prefetch(); } } Prefetching the Media
  • 9. Adding Player to your Application  Adding the player to application is actually kind of tricky .  The player itself is not an AWT component. So you don’t add the player it self ,but it’s visual representation.  To get the visual component ,player has a method called getVisualComponent().  Player has a method called getState() that returns the state of the current player .  ControllerListener has one method- ControllerUpdate(ControllerEvent).
  • 10.  We can use the ControllerUpdate method to know when the media has been fetched.  ControllerUpdate() method is called each time the state of the controller changes. Example: Adding Player to your Application public synchronized void control update(ControllerEvent event) { if(event instanceof RealizeCompleteEvent) { if((VisualComponent = player.getVisualCompent())!=null) add(“center”,visualComponent); validate(); } }
  • 11. Registering the Applet as a Listener  To have the player call ControllerUpdate() you must first register your application with the player.  Just like all java.awt.event listener after a component has been registered as listener ,it’s the method will be call any time an event occurs.  For the current purposes you will add the addControllerListener code to the init() method of the applet.
  • 12. Public void init() { String mediaFile =null; URL mediaURL=null; setLayout(new BorderLayout()); If((mediaFile=getParameter(“file”))==null) { System.err.print(“Media file not present”); System.err.print(“Required parameter is ‘file’ ”); } else { try { mediaURL = new URL(getDocumentBase(),mediafile); player=manager.createPlayer(mediaURL); } } Registering the Applet as a Listener
  • 13. Starting the Player  start() which tells player to start. The more fundamental methods allows to start the player and specify when it will actually display it’s media.  The syncstart() method is the method that actually causes the player to start. Example : If(event instanceof PrefetchCompleteEvent) { player.start(); }
  • 14. Cleaning Up and Stopping the Player  stop() method must be used to stop the media player and clean up.  The stop() method is called when browser leaves the current web pages. After browser leaves the page, we should stop playing the current media.  One addition step we should take-removing the media from memory. The player has deallocate() method. As soon as you know that you no longer need a media ,you should tell the player to deallocate it so that it can be garbage collected.
  • 15.  Using both the player’s stop() and deallcoate() methods, you can create the applets stop method. Example: Public void stop() { if(player!=null) { player.deallocate(); } } Cleaning Up and Stopping the Player
  • 16. States of the Players  There are different states that player goes through during normal operation. Unrealized realize() Realizing Realized Prefetch() Prefetching Prefetch Start()/deallocate() Start deallocate()
  • 17.  Unrealized: At this stage, the player does not know anything about the media except what the URL to the media is.  Realizing: In the realizing state, the player acquired all of resources that are non-exclusive.  Realized: When the player enters the realized state, the RealizeCompleteEvent is issued.  Prefetching: To get the player to move into the prefetching state, you can use the prefetch() method. States of the Players
  • 18.  Prefetched :Entering the prefetched state, a player issues the PrefetchCompleteEvent.  Started : When player is started, it enters the started state. States of the Players
  • 19. Adding Controls to the Players Example: Public synchronized void controllerUpdate(ControllerEvent event) { if(event isnstaceofRealizeCompleteEvent) { if((visualComponent =player.getVisualComponent())!=null) if(visualComponent!=null) add(“South”,controlComponent); else add(“Center”,controlComponent); }}  Each type of the player has the capability to give you a set of controls using the ControlPanelComponent() method.  Like the getVisualComponent() method, the getControlPanelComponent() cannot be used until after the player has been realized.
  • 20. Setting the media time and Changing rate  The setMediaTime() method takes long parameter and that number represents the time in nanoseconds.  The setRate() method returns to you the actual rate that has been applied. Example : if(event isnstaceofPrefetchCompleteEvent) { System.out.println(“Prefetching : ” + newDate()); player.setRate((float)2.0); player.start(); }
  • 21. Features of JMF  JMF supports many popular media formats such as JPEG, MPEG-1, MPEG-2, QuickTime, AVI, WAV, MP3, GSM, G723, H263, and MIDI.  JMF supports popular media access protocols such as file, HTTP, HTTPS, FTP, RTP, and RTSP.  JMF uses a well-defined event reporting mechanism that follows the “Observer” design pattern. JMF uses the “Factory” design pattern that simplifies the creation of JMF objects.  The JMF support the reception and transmission of media streams using Real-time Transport Protocol (RTP) and JMF supports management of RTP sessions.
  • 22. References  Book: Advanced JAVA  Websites:  http://www.programming.com/GepBook/Chapter7/M3L1.p pt  https://web.cs.dal.ca/~mheywood/CSCI6506/HandOuts/N 04-Deception.pdf
  • 23. Thank you . . .!!!!!