# Class MediaContainer

java.lang.Object
javax.media.j3d.SceneGraphObject
javax.media.j3d.NodeComponent
javax.media.j3d.MediaContainer

public class MediaContainer extends NodeComponent
The MediaContainer object defines all sound data: cached state flag, and associated sound media. Currently this references the sound media in one of three forms: URL String, URL object, or InputStream object. In future releases media data will include references to Java Media Player objects. Only one type of sound media data specified using `setURLString`, `setURLObject`, or `setInputStream` may be non-null (or they may all be null). An attempt to set more than one of these attributes to a non-null reference will result in an exception being thrown. If all sound media data references are null, there is no sound associated with this MediaContainer and Sound nodes referencing this object cannot be played.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ALLOW_CACHE_READ`
For MediaContainer component objects, specifies that this object allows the reading of its cached flag.
`static final int`
`ALLOW_CACHE_WRITE`
For MediaContainer component objects, specifies that this object allows the writing of its cached flag.
`static final int`
`ALLOW_URL_READ`
For MediaContainer component objects, specifies that this object allows the reading of it's sound data.
`static final int`
`ALLOW_URL_WRITE`
For MediaContainer component objects, specifies that this object allows the writing of it's URL path.

## Constructor Summary

Constructors
Constructor
Description
`MediaContainer()`
Constructs a MediaContainer object with default parameters.
`MediaContainer(InputStream stream)`
Constructs and initializes a MediaContainer object using specified parameters.
`MediaContainer(String path)`
Constructs and initializes a MediaContainer object using specified parameters.
`MediaContainer(URL url)`
Constructs and initializes a MediaContainer object using specified parameters.

## Method Summary

Modifier and Type
Method
Description
`NodeComponent`
`cloneNodeComponent()`
Deprecated.
As of Java 3D version 1.2, replaced with `cloneNodeComponent(boolean forceDuplicate)`
`boolean`
`getCacheEnable()`
Retrieve Cache Enable state flag.
`InputStream`
`getInputStream()`
Retrieve Input Stream.
`String`
`getURL()`
Deprecated.
As of Java 3D version 1.2, replaced by `getURLString`
`URL`
`getURLObject()`
Retrieve URL Object.
`String`
`getURLString()`
Retrieve URL String.
`void`
`setCacheEnable(boolean flag)`
Set Cache Enable state flag.
`void`
`setInputStream(InputStream stream)`
Set Input Stream.
`void`
`setURL(String path)`
Deprecated.
As of Java 3D version 1.2, replaced by `setURLString`
`void`
`setURL(URL url)`
Deprecated.
As of Java 3D version 1.2, replaced by `setURLObject`
`void`
`setURLObject(URL url)`
Set URL Object.
`void`
`setURLString(String path)`
Set URL String.

### Methods inherited from class NodeComponent

`cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree`

### Methods inherited from class SceneGraphObject

`clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### ALLOW_CACHE_READ

public static final int ALLOW_CACHE_READ
For MediaContainer component objects, specifies that this object allows the reading of its cached flag.

See Also:
  - Constant Field Values

### ALLOW_CACHE_WRITE

public static final int ALLOW_CACHE_WRITE
For MediaContainer component objects, specifies that this object allows the writing of its cached flag.

See Also:
  - Constant Field Values

### ALLOW_URL_READ

public static final int ALLOW_URL_READ
For MediaContainer component objects, specifies that this object allows the reading of it's sound data.

See Also:
  - Constant Field Values

### ALLOW_URL_WRITE

public static final int ALLOW_URL_WRITE
For MediaContainer component objects, specifies that this object allows the writing of it's URL path.

See Also:
  - Constant Field Values

## Constructor Details

### MediaContainer

public MediaContainer()
Constructs a MediaContainer object with default parameters. The default values are as follows:

URL String data : null
URL object data : null
InputStream data : null
cache enable : true

### MediaContainer

public MediaContainer(String path)
Constructs and initializes a MediaContainer object using specified parameters.

Parameters:
  `path` - string of URL path containing sound data
Throws:
  `SoundException` - if the URL is not valid or cannot be opened

### MediaContainer

public MediaContainer(URL url)
Constructs and initializes a MediaContainer object using specified parameters.

Parameters:
  `url` - URL path containing sound data
Throws:
  `SoundException` - if the URL is not valid or cannot be opened

### MediaContainer

public MediaContainer(InputStream stream)
Constructs and initializes a MediaContainer object using specified parameters.

Parameters:
  `stream` - input stream containing sound data
Since:
  Java 3D 1.2

## Method Details

### setCacheEnable

public void setCacheEnable(boolean flag)
Set Cache Enable state flag. Allows the writing of sound data explicitly into the MediaContainer rather than just referencing a JavaMedia container.

Parameters:
  `flag` - boolean denoting if sound data is cached in this instance
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### getCacheEnable

public boolean getCacheEnable()
Retrieve Cache Enable state flag.

Returns:
  flag denoting is sound data is non-cached or cached
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### setURL

public void setURL(String path)
Deprecated.
As of Java 3D version 1.2, replaced by `setURLString`

### setURL

public void setURL(URL url)
Deprecated.
As of Java 3D version 1.2, replaced by `setURLObject`

### setURLString

public void setURLString(String path)
Set URL String.

Parameters:
  `path` - string of URL containing sound data
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `SoundException` - if the URL is not valid or cannot be opened
  `IllegalArgumentException` - if the specified sound data is non-null and any other sound data reference is also non-null.
Since:
  Java 3D 1.2

### setURLObject

public void setURLObject(URL url)
Set URL Object.

Parameters:
  `url` - URL object containing sound data
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `SoundException` - if the URL is not valid or cannot be opened
  `IllegalArgumentException` - if the specified sound data is non-null and any other sound data reference is also non-null.
Since:
  Java 3D 1.2

### setInputStream

public void setInputStream(InputStream stream)
Set Input Stream.

Parameters:
  `stream` - input stream object containing sound data
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `SoundException` - if InputStream is bad
  `IllegalArgumentException` - if the specified sound data is non-null and any other sound data reference is also non-null.
Since:
  Java 3D 1.2

### getURL

public String getURL()
Deprecated.
As of Java 3D version 1.2, replaced by `getURLString`

### getURLString

public String getURLString()
Retrieve URL String.

Returns:
  string of URL containing sound data
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
  Java 3D 1.2

### getURLObject

public URL getURLObject()
Retrieve URL Object.

Returns:
  URL containing sound data
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
  Java 3D 1.2

### getInputStream

public InputStream getInputStream()
Retrieve Input Stream.

Returns:
  reference to input stream containing sound data
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
  Java 3D 1.2

### cloneNodeComponent

public NodeComponent cloneNodeComponent()
Deprecated.
As of Java 3D version 1.2, replaced with `cloneNodeComponent(boolean forceDuplicate)`

Overrides:
  `cloneNodeComponent` in class `NodeComponent`