SlideShare a Scribd company logo
By Marcel Caraciolo http://mobideia.blogspot.com Chapter  12–  MIDP Sound API SCMAD Certification  45mm 61mm
Agenda MIDP – Sound API Sound API Manager Player Control Controllable PlayerListener Controls
MIDP Sound API MIDP defines a basic sound API. MMAPI (Mobile Media API) provides  support to more sophisticated media devices, an its API extends MIDP’s. It will be descrived on the next chapter. Devices must at least be able to generate monophonic tones. Allows playing recorded media (independently of the encoding), tone generation and controls (e.g. volume). Video is not supported. MMAPI is required for handling video. Media files may be downloaded from the network or packaged on the JAR.
MIDP Sound API Minimum requirements: Tone generation If recorded media is supported,  PCM wav 8 bit, 8 KHZ  format must be supported. Additional formats may be supported MIDI may be supported Like network operations, media operations must also be executed on separate threads, because resource loading and infrastructure access may consume time. A resource execution (start method) is not blocking ONLY when all resources are already loaded. Classes at  javax.microedition.media  package. API is based on three main classes: Manager, Player and Control.
M Manager Factory to create Players, which execute media operations All methods are static Factory methods:  Manager.createPlayer()
M Manager Players may be created from: A media locator:  URL that defines origin and content type to be processed. There are three types of media locator: An URL referencing a resource to be executed (e.g.  http://server/music.mid  or  rtp://host/type).  The content type is part of the response header and the content is part of the response body. A device to generate sound programmatically. (e.g.  device://tone or device:// midi) .  An “empty” player is created, and sound is created programmatically. An URL accessing a media capture device (e.g.  capture:// audio,  capture:// video, capture://radio)
M Manager Players may be created from: An input stream:  For instance, the stream can be from a JAR resource or from the network. The content type may be discovered from the content. A  DataSource  (MMAPI only): Class that handles “fetching” data, decoupling data from its source and access protocol.
M Manager: methods Players may be created from: playTone(note,duration,volume):  Convenience method to play a tone. Plays a tone (integer from 0 to 127), during the specified time (milliseconds) using the specified volume ( 0 – 100). This method is non-blocking. getSupportedContentTypes(protocol):  Gets all supported content types for a specific protocol.  If protocol is null, all supported content types are returned. Content types examples: audio/x-wav (PCM wav) audio/midi (MIDI) audio/x-tone-seq (Tone sequencing) audio/mpeg (MP3) video / mpeg (MPEG video)
M Manager: methods Players may be created from: getSupportedProtocols(content_type):  Gets all protocols that can be used to access some content type (e.g. HTTP RTP). If  null  is informed, all protocols that can be used to access media are returned. createPlayer(locator):  Creates a player from a specified locator. createPlayer(stream,type):  Creates a player from stream, to execute the specified content type. If the type is null, the device will try to find out the content based on the stream’s content. createPlayer(dataSource):  Creates a player using dataSource. (Available only at MMAPI).
MP Player Interface Controls  media execution Players  are created using Manager’s factory methods, and the media executions begins calling start() method. If all data is already loaded, this call is not blocking. If not interrupted, the execution proceeds until the end of the media.
MP Player: Life cycle These are the player’s states: UNREALIZED:  Right after its creation. No data is loaded, hence the following methods cannot be called: getContentType setTimeBase/ getTimeBase setMediaTime getControl/ getControls REALIZED:  Resources were fetched. Resource information is available and its content is possibly loaded.
MP Player: Life cycle These are the player’s states (Continuing): PREFETCHED:  Resources were loaded and are available to execution, probably already on the output buffers. When the execution is finished, the player returns to this state. STARTED:  Execution has started and has not finished. CLOSED:  Player is closed. Resources are freed and the player cannot be reused.
MP Player: Life cycle When you create, start, wait for the media end and close a player , the life cycle is: UNREALIZED REALIZED PREFETCHED STARTED PREFETCHED CLOSED
MP Player: Methods getDuration():  Media duration. If it’s undefined (e.g. for live transmission streams)  TIME_UNKNOWN  is returned. getContentType():  Media’s content type. getState():  Current state ( UNREALIZED, REALIZED, PREFETCHED, STARTED or CLOSED). realize(), prefetch() :  Requests a start change. If it’s in a more advanced state (e.g. calling realize on  PREFETCHED  player) the call is ignored. These methods ARE blocking.
MP Player: Methods start():  Starts the media execution. If the player is not at  PREFETCHED  state, it will be prefetched before the execution starts.  If it’s already executing, the call is ignored. If it’s called on a interrupted player (interrupted by stop or media end) the execution continues from the point where it stopped. It’s not blocking if the player is  PREFETCHED. stop():  Stops the execution at the current point. deallocate():  Deallocate all player’s resources and it returns it to  REALIZED  state. Useful for devices that do not support mixing and the buffers must be freed if another resource is to be executed. close():  Finishes a player and deallocates all the resources it consumes.
MP Player: Methods setMediaTime(now):  Sets the execution on a specific time. If it’s a negative value, the media returns at the beginning. If it’s bigger than the resource duration, it goes to the end. Some resources may not support this operation (e.g. live transmissions). setLoopCount(count):  Repeats the media execution. By default it’s 1.  Setting 0 is not valid and setting -1 repeats indefinitely. It cannot be called by a  STARTED  player. addPlayerListener(playerlistener), removePlayerListener(playerListener):  Adds/Removes an event listener, which is notified everytime a player changes its state. Event ordering is kept.
MP Control Marker interface (define no methods) Controls the execution of processing of some media type. Examples: VolumeControl FramePositioningControl RecordControl A player may have several controls
MP Controllable Controllable: Object that “has controls”. Player implements Controllable. Methods: getControls():  All controls supported by the object getControl(controlType):  Gets a control from its class name. If this control is not supported, null is returned. If the package name is omitted, it’s assumed that it belongs to  javax.microedition.media  package.
MP Controllable PlayerListener: Receives  player’s events notifications. Events are represented as strings so that new events may be added without changing the interface. Event samples: STARTED STOPPED END_OF_MEDIA VOLUME_CHANGED ERROR CLOSED Method:  playerUpdate(player,event,eventData):  An event has happened on this player with the parameter data.
MP  Controls: VolumeControl Volume handling control. Volume value goes from 0 to 100 (inclusive). Mute may be set, which silents the media output but does not change the value returned by getLevel(). Must be implemented by player that execute sample audio (e.g. wav), generated audio (e.g. MIDI or tones) and video with sound. Methods: setMute(boolean) isMuted() setLevel(level) getLevel()
MP  Controls: ToneControl Plays a monophonic media sequence. A player is obtained by  Manager.TONE_DEVICE_LOCATOR  locator.  It’s an important control because this might be the only way to produce music on rudimentary devices. Defines the setSequence( byte[])  method to set the media sequence. A sequence is defined by pairs that specify, on this order: Version Tempo Resolution Blocks Events
To Tone Control: Sample Example
Example Codes Some examples and MIDlets samples are available for reference and studying  at this link: http://www.dsc.upe.br/~ mpc/chapter12.rar The source codes include: SoundPlayerMIDlet
Future Work Next Chapter: MIDP – MMAPI
References ALVES F. Eduardo. SCMAD Study Guide,  27/04/2008.  JAKL Andreas, Java Platform, Micro Edition Part  01 slides, 12/2007. Sun Certification Mobile Application Developer  Website:  [http://www.sun.com/training/certification/java/scmad.xml].

More Related Content

PPTX
PPT
Cse191 01
PPTX
Archimedia atlas visual_orientation_slideshow
PDF
Can You Hear Me Now? Exercises
PPS
Niver Flavia - 26.08.07
PPS
Massao - 10.06.07
KEY
Syracuse University SIFE Team Guatemala
PDF
Cse191 01
Archimedia atlas visual_orientation_slideshow
Can You Hear Me Now? Exercises
Niver Flavia - 26.08.07
Massao - 10.06.07
Syracuse University SIFE Team Guatemala

Viewers also liked (20)

PPT
Google既有商業模式的破壞者3
PPT
My Mom On Leadership
PDF
Tnt 20 jan pdf
PPS
Lec Movie - 03.11.07
PPT
Totara Seminar: Wendy Henry, Lincolnshire
PPTX
Paper Based Student Enrollment - Disgrace to Education Technology
PPT
Scmad Chapter08
PPTX
Dr Andrew Larner - Sector Self Help
KEY
Social media school 2011 oktober
PPT
Social Care e-learning from Learning Pool & Ophira
PDF
Sierra Bermeja Trail. Nueva Temporada 2017
PPT
عرض ملتقى النهائي جديد
PPS
Acampa2007
PDF
Lecture 18
PDF
Le 10 lezioni che ho imparato negli ultimi 15 anni
PPTX
Systems engineering leidraad se gww door ms
PPT
Customizing HTML Outputs From Author-It
PPT
香港六合彩
KEY
Lezing abc
PPT
lezing Online netwerken
Google既有商業模式的破壞者3
My Mom On Leadership
Tnt 20 jan pdf
Lec Movie - 03.11.07
Totara Seminar: Wendy Henry, Lincolnshire
Paper Based Student Enrollment - Disgrace to Education Technology
Scmad Chapter08
Dr Andrew Larner - Sector Self Help
Social media school 2011 oktober
Social Care e-learning from Learning Pool & Ophira
Sierra Bermeja Trail. Nueva Temporada 2017
عرض ملتقى النهائي جديد
Acampa2007
Lecture 18
Le 10 lezioni che ho imparato negli ultimi 15 anni
Systems engineering leidraad se gww door ms
Customizing HTML Outputs From Author-It
香港六合彩
Lezing abc
lezing Online netwerken
Ad

Similar to Scmad Chapter12 (20)

PPT
J2me
PDF
MIDP: Music and Sound
PPT
Scmad Chapter13
PPT
Jsr135 sup
PDF
Android media framework overview
PDF
mjar
PPTX
Android Multimedia Player Project Presentation
PPT
Java Media Framework API
PDF
Making an OpenSource Automotive IVI Media Manager
 
PPTX
Java media framework
PDF
Songbird
PDF
Multimedia on android
PPTX
Loading viewing/listening to Image and Audio, Fonts, Colors in Java
PPTX
Mp3 player
DOCX
Android media-chapter 23
PPTX
Designing of media player
PPT
Prasentation Managed DirectX
PPT
Chapter GFHFHFHFHFJHFGHFHFJHHJHGJHGH09.ppt
PDF
Module 2 3
PDF
L034072076
J2me
MIDP: Music and Sound
Scmad Chapter13
Jsr135 sup
Android media framework overview
mjar
Android Multimedia Player Project Presentation
Java Media Framework API
Making an OpenSource Automotive IVI Media Manager
 
Java media framework
Songbird
Multimedia on android
Loading viewing/listening to Image and Audio, Fonts, Colors in Java
Mp3 player
Android media-chapter 23
Designing of media player
Prasentation Managed DirectX
Chapter GFHFHFHFHFJHFGHFHFJHHJHGJHGH09.ppt
Module 2 3
L034072076
Ad

More from Marcel Caraciolo (20)

PDF
Como interpretar seu próprio genoma com Python
PDF
Joblib: Lightweight pipelining for parallel jobs (v2)
PDF
Construindo softwares de bioinformática para análises clínicas : Desafios e...
PDF
Como Python ajudou a automatizar o nosso laboratório v.2
PDF
Como Python pode ajudar na automação do seu laboratório
PDF
Python on Science ? Yes, We can.
PDF
Oficina Python: Hackeando a Web com Python 3
PDF
Recommender Systems with Ruby (adding machine learning, statistics, etc)
PDF
Opensource - Como começar e dá dinheiro ?
PDF
Big Data com Python
PDF
Benchy, python framework for performance benchmarking of Python Scripts
PDF
Python e 10 motivos por que devo conhece-la ?
PDF
GeoMapper, Python Script for Visualizing Data on Social Networks with Geo-loc...
PDF
Benchy: Lightweight framework for Performance Benchmarks
PDF
Construindo Sistemas de Recomendação com Python
PDF
Python, A pílula Azul da programação
PDF
Construindo Soluções Científicas com Big Data & MapReduce
PDF
Como Python está mudando a forma de aprendizagem à distância no Brasil
PDF
Novas Tendências para a Educação a Distância: Como reinventar a educação ?
PDF
Aula WebCrawlers com Regex - PyCursos
Como interpretar seu próprio genoma com Python
Joblib: Lightweight pipelining for parallel jobs (v2)
Construindo softwares de bioinformática para análises clínicas : Desafios e...
Como Python ajudou a automatizar o nosso laboratório v.2
Como Python pode ajudar na automação do seu laboratório
Python on Science ? Yes, We can.
Oficina Python: Hackeando a Web com Python 3
Recommender Systems with Ruby (adding machine learning, statistics, etc)
Opensource - Como começar e dá dinheiro ?
Big Data com Python
Benchy, python framework for performance benchmarking of Python Scripts
Python e 10 motivos por que devo conhece-la ?
GeoMapper, Python Script for Visualizing Data on Social Networks with Geo-loc...
Benchy: Lightweight framework for Performance Benchmarks
Construindo Sistemas de Recomendação com Python
Python, A pílula Azul da programação
Construindo Soluções Científicas com Big Data & MapReduce
Como Python está mudando a forma de aprendizagem à distância no Brasil
Novas Tendências para a Educação a Distância: Como reinventar a educação ?
Aula WebCrawlers com Regex - PyCursos

Recently uploaded (20)

PDF
Visual Performance Enhancement in Sports Optometry
DOCX
NFL Dublin Labriola on Steelers’ Victory Over the Jaguars.docx
DOCX
FA Cup Final 2026 Siring: Arne Slot Crit
PPTX
Sports Writing by SHS Teacher Roel A. Naza
PDF
BOOK MUAYTHAI THAI FIGHT ALEXANDRE BRECK
PDF
Understanding Volunteering_ A Look at Its True Meaning by David Bennett Gallo...
DOCX
FIFA World Cup Semi Final The Battle for Global Supremacy.docx
DOCX
NFL Dublin Vikings Turn to Speed with Tai Felton.docx
PPTX
Best All-Access Digital Pass me .pptxxxx
DOCX
North Texas announced as base camps for 2026 FIFA World Cup.docx
PDF
aasm 8/22-23 Schedule of Oral Presentation.pdf
DOCX
NFL London Broncos Set Sights on 2025 Season.docx
DOCX
NFL Dublin Rondale Moore’s Comeback Ends in Heartbreak.docx
PPTX
Badminton Sport group presentation pathfit
PPTX
Orange and Colorful History Of Sport Club Presentation.pptx
PDF
aaam 8/22-23 Schedule of Poster Presentation.pdf
PPTX
ttttttttttttttttttttttttarget games.pptx
PPT
Aboriginals Achievements in Society and Community Development
PPTX
India – The Diverse and Dynamic Country | TIDA Sports
DOCX
NFL London Jets QB Room Dealing with Multiple Injuries.docx
Visual Performance Enhancement in Sports Optometry
NFL Dublin Labriola on Steelers’ Victory Over the Jaguars.docx
FA Cup Final 2026 Siring: Arne Slot Crit
Sports Writing by SHS Teacher Roel A. Naza
BOOK MUAYTHAI THAI FIGHT ALEXANDRE BRECK
Understanding Volunteering_ A Look at Its True Meaning by David Bennett Gallo...
FIFA World Cup Semi Final The Battle for Global Supremacy.docx
NFL Dublin Vikings Turn to Speed with Tai Felton.docx
Best All-Access Digital Pass me .pptxxxx
North Texas announced as base camps for 2026 FIFA World Cup.docx
aasm 8/22-23 Schedule of Oral Presentation.pdf
NFL London Broncos Set Sights on 2025 Season.docx
NFL Dublin Rondale Moore’s Comeback Ends in Heartbreak.docx
Badminton Sport group presentation pathfit
Orange and Colorful History Of Sport Club Presentation.pptx
aaam 8/22-23 Schedule of Poster Presentation.pdf
ttttttttttttttttttttttttarget games.pptx
Aboriginals Achievements in Society and Community Development
India – The Diverse and Dynamic Country | TIDA Sports
NFL London Jets QB Room Dealing with Multiple Injuries.docx

Scmad Chapter12

  • 1. By Marcel Caraciolo http://mobideia.blogspot.com Chapter 12– MIDP Sound API SCMAD Certification 45mm 61mm
  • 2. Agenda MIDP – Sound API Sound API Manager Player Control Controllable PlayerListener Controls
  • 3. MIDP Sound API MIDP defines a basic sound API. MMAPI (Mobile Media API) provides support to more sophisticated media devices, an its API extends MIDP’s. It will be descrived on the next chapter. Devices must at least be able to generate monophonic tones. Allows playing recorded media (independently of the encoding), tone generation and controls (e.g. volume). Video is not supported. MMAPI is required for handling video. Media files may be downloaded from the network or packaged on the JAR.
  • 4. MIDP Sound API Minimum requirements: Tone generation If recorded media is supported, PCM wav 8 bit, 8 KHZ format must be supported. Additional formats may be supported MIDI may be supported Like network operations, media operations must also be executed on separate threads, because resource loading and infrastructure access may consume time. A resource execution (start method) is not blocking ONLY when all resources are already loaded. Classes at javax.microedition.media package. API is based on three main classes: Manager, Player and Control.
  • 5. M Manager Factory to create Players, which execute media operations All methods are static Factory methods: Manager.createPlayer()
  • 6. M Manager Players may be created from: A media locator: URL that defines origin and content type to be processed. There are three types of media locator: An URL referencing a resource to be executed (e.g. http://server/music.mid or rtp://host/type). The content type is part of the response header and the content is part of the response body. A device to generate sound programmatically. (e.g. device://tone or device:// midi) . An “empty” player is created, and sound is created programmatically. An URL accessing a media capture device (e.g. capture:// audio, capture:// video, capture://radio)
  • 7. M Manager Players may be created from: An input stream: For instance, the stream can be from a JAR resource or from the network. The content type may be discovered from the content. A DataSource (MMAPI only): Class that handles “fetching” data, decoupling data from its source and access protocol.
  • 8. M Manager: methods Players may be created from: playTone(note,duration,volume): Convenience method to play a tone. Plays a tone (integer from 0 to 127), during the specified time (milliseconds) using the specified volume ( 0 – 100). This method is non-blocking. getSupportedContentTypes(protocol): Gets all supported content types for a specific protocol. If protocol is null, all supported content types are returned. Content types examples: audio/x-wav (PCM wav) audio/midi (MIDI) audio/x-tone-seq (Tone sequencing) audio/mpeg (MP3) video / mpeg (MPEG video)
  • 9. M Manager: methods Players may be created from: getSupportedProtocols(content_type): Gets all protocols that can be used to access some content type (e.g. HTTP RTP). If null is informed, all protocols that can be used to access media are returned. createPlayer(locator): Creates a player from a specified locator. createPlayer(stream,type): Creates a player from stream, to execute the specified content type. If the type is null, the device will try to find out the content based on the stream’s content. createPlayer(dataSource): Creates a player using dataSource. (Available only at MMAPI).
  • 10. MP Player Interface Controls media execution Players are created using Manager’s factory methods, and the media executions begins calling start() method. If all data is already loaded, this call is not blocking. If not interrupted, the execution proceeds until the end of the media.
  • 11. MP Player: Life cycle These are the player’s states: UNREALIZED: Right after its creation. No data is loaded, hence the following methods cannot be called: getContentType setTimeBase/ getTimeBase setMediaTime getControl/ getControls REALIZED: Resources were fetched. Resource information is available and its content is possibly loaded.
  • 12. MP Player: Life cycle These are the player’s states (Continuing): PREFETCHED: Resources were loaded and are available to execution, probably already on the output buffers. When the execution is finished, the player returns to this state. STARTED: Execution has started and has not finished. CLOSED: Player is closed. Resources are freed and the player cannot be reused.
  • 13. MP Player: Life cycle When you create, start, wait for the media end and close a player , the life cycle is: UNREALIZED REALIZED PREFETCHED STARTED PREFETCHED CLOSED
  • 14. MP Player: Methods getDuration(): Media duration. If it’s undefined (e.g. for live transmission streams) TIME_UNKNOWN is returned. getContentType(): Media’s content type. getState(): Current state ( UNREALIZED, REALIZED, PREFETCHED, STARTED or CLOSED). realize(), prefetch() : Requests a start change. If it’s in a more advanced state (e.g. calling realize on PREFETCHED player) the call is ignored. These methods ARE blocking.
  • 15. MP Player: Methods start(): Starts the media execution. If the player is not at PREFETCHED state, it will be prefetched before the execution starts. If it’s already executing, the call is ignored. If it’s called on a interrupted player (interrupted by stop or media end) the execution continues from the point where it stopped. It’s not blocking if the player is PREFETCHED. stop(): Stops the execution at the current point. deallocate(): Deallocate all player’s resources and it returns it to REALIZED state. Useful for devices that do not support mixing and the buffers must be freed if another resource is to be executed. close(): Finishes a player and deallocates all the resources it consumes.
  • 16. MP Player: Methods setMediaTime(now): Sets the execution on a specific time. If it’s a negative value, the media returns at the beginning. If it’s bigger than the resource duration, it goes to the end. Some resources may not support this operation (e.g. live transmissions). setLoopCount(count): Repeats the media execution. By default it’s 1. Setting 0 is not valid and setting -1 repeats indefinitely. It cannot be called by a STARTED player. addPlayerListener(playerlistener), removePlayerListener(playerListener): Adds/Removes an event listener, which is notified everytime a player changes its state. Event ordering is kept.
  • 17. MP Control Marker interface (define no methods) Controls the execution of processing of some media type. Examples: VolumeControl FramePositioningControl RecordControl A player may have several controls
  • 18. MP Controllable Controllable: Object that “has controls”. Player implements Controllable. Methods: getControls(): All controls supported by the object getControl(controlType): Gets a control from its class name. If this control is not supported, null is returned. If the package name is omitted, it’s assumed that it belongs to javax.microedition.media package.
  • 19. MP Controllable PlayerListener: Receives player’s events notifications. Events are represented as strings so that new events may be added without changing the interface. Event samples: STARTED STOPPED END_OF_MEDIA VOLUME_CHANGED ERROR CLOSED Method: playerUpdate(player,event,eventData): An event has happened on this player with the parameter data.
  • 20. MP Controls: VolumeControl Volume handling control. Volume value goes from 0 to 100 (inclusive). Mute may be set, which silents the media output but does not change the value returned by getLevel(). Must be implemented by player that execute sample audio (e.g. wav), generated audio (e.g. MIDI or tones) and video with sound. Methods: setMute(boolean) isMuted() setLevel(level) getLevel()
  • 21. MP Controls: ToneControl Plays a monophonic media sequence. A player is obtained by Manager.TONE_DEVICE_LOCATOR locator. It’s an important control because this might be the only way to produce music on rudimentary devices. Defines the setSequence( byte[]) method to set the media sequence. A sequence is defined by pairs that specify, on this order: Version Tempo Resolution Blocks Events
  • 22. To Tone Control: Sample Example
  • 23. Example Codes Some examples and MIDlets samples are available for reference and studying at this link: http://www.dsc.upe.br/~ mpc/chapter12.rar The source codes include: SoundPlayerMIDlet
  • 24. Future Work Next Chapter: MIDP – MMAPI
  • 25. References ALVES F. Eduardo. SCMAD Study Guide, 27/04/2008. JAKL Andreas, Java Platform, Micro Edition Part 01 slides, 12/2007. Sun Certification Mobile Application Developer Website: [http://www.sun.com/training/certification/java/scmad.xml].