SlideShare a Scribd company logo
1 of 23
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

What's hot (20)

File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
Packages in java
Packages in javaPackages in java
Packages in java
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Java - Sockets
Java - SocketsJava - Sockets
Java - Sockets
 
Java Media Framework API
Java Media Framework APIJava Media Framework API
Java Media Framework API
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Java non access modifiers
Java non access modifiersJava non access modifiers
Java non access modifiers
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mounting
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
 
Web server
Web serverWeb server
Web server
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Coda file system
Coda file systemCoda file system
Coda file system
 
Json
JsonJson
Json
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
Files in java
Files in javaFiles in java
Files in java
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 

Similar to Java media framework

Yapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web PlayerYapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web PlayerJesse (Chien Chen) Chen
 
Adobe OSMF Overview
Adobe OSMF OverviewAdobe OSMF Overview
Adobe OSMF OverviewYoss Cohen
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driverPankaj Biswas
 
Jsr135 sup
Jsr135 supJsr135 sup
Jsr135 supSMIJava
 
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...Amazon Appstore Developers
 
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands OnjBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands OnMauricio (Salaboy) Salatino
 
Android internals By Rajesh Khetan
Android internals By Rajesh KhetanAndroid internals By Rajesh Khetan
Android internals By Rajesh KhetanRajesh Khetan
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 appletsraksharao
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - IntroductionFrancis Seriña
 
Basic Static Malware Analysis.pdf
Basic Static Malware Analysis.pdfBasic Static Malware Analysis.pdf
Basic Static Malware Analysis.pdfVINAY GATLA
 
Download and restrict video files in android app
Download and restrict video files in android appDownload and restrict video files in android app
Download and restrict video files in android appKaty Slemon
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docxalfred4lewis58146
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 

Similar to Java media framework (20)

Yapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web PlayerYapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web Player
 
Adobe OSMF Overview
Adobe OSMF OverviewAdobe OSMF Overview
Adobe OSMF Overview
 
Dense And Hot Web Du
Dense And Hot  Web DuDense And Hot  Web Du
Dense And Hot Web Du
 
Dense And Hot 360 Flex
Dense And Hot 360 FlexDense And Hot 360 Flex
Dense And Hot 360 Flex
 
Scmad Chapter12
Scmad Chapter12Scmad Chapter12
Scmad Chapter12
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driver
 
Jsr135 sup
Jsr135 supJsr135 sup
Jsr135 sup
 
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands OnjBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
 
Android internals By Rajesh Khetan
Android internals By Rajesh KhetanAndroid internals By Rajesh Khetan
Android internals By Rajesh Khetan
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - Introduction
 
Basic Static Malware Analysis.pdf
Basic Static Malware Analysis.pdfBasic Static Malware Analysis.pdf
Basic Static Malware Analysis.pdf
 
Download and restrict video files in android app
Download and restrict video files in android appDownload and restrict video files in android app
Download and restrict video files in android app
 
Ph
PhPh
Ph
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
 
6.C#
6.C# 6.C#
6.C#
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Scmad Chapter13
Scmad Chapter13Scmad Chapter13
Scmad Chapter13
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

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 . . .!!!!!