Search in sources :

Example 26 with IllegalArgumentException

use of java.lang.IllegalArgumentException in project XobotOS by xamarin.

the class SIPDate method setHour.

/**
     * Set the hour member
     * @param h int to set
     * @throws IllegalArgumentException if h is not a valid hour.
     */
public void setHour(int h) throws IllegalArgumentException {
    if (h < 0 || h > 24)
        throw new IllegalArgumentException("Illegal hour : " + h);
    javaCal = null;
    hour = h;
}
Also used : IllegalArgumentException(java.lang.IllegalArgumentException)

Example 27 with IllegalArgumentException

use of java.lang.IllegalArgumentException in project XobotOS by xamarin.

the class AudioRecord method audioBuffSizeCheck.

// Convenience method for the contructor's audio buffer size check.
// preconditions:
//    mChannelCount is valid
//    mAudioFormat is AudioFormat.ENCODING_PCM_8BIT OR AudioFormat.ENCODING_PCM_16BIT
// postcondition:
//    mNativeBufferSizeInBytes is valid (multiple of frame size, positive)
private void audioBuffSizeCheck(int audioBufferSize) {
    // NB: this section is only valid with PCM data. 
    // To update when supporting compressed formats
    int frameSizeInBytes = mChannelCount * (mAudioFormat == AudioFormat.ENCODING_PCM_8BIT ? 1 : 2);
    if ((audioBufferSize % frameSizeInBytes != 0) || (audioBufferSize < 1)) {
        throw (new IllegalArgumentException("Invalid audio buffer size."));
    }
    mNativeBufferSizeInBytes = audioBufferSize;
}
Also used : IllegalArgumentException(java.lang.IllegalArgumentException)

Example 28 with IllegalArgumentException

use of java.lang.IllegalArgumentException in project android_frameworks_base by DirtyUnicorns.

the class MediaSource method setupMediaPlayer.

/** Creates a media player, sets it up, and calls prepare */
private synchronized boolean setupMediaPlayer(boolean useUrl) {
    mPrepared = false;
    mGotSize = false;
    mPlaying = false;
    mPaused = false;
    mCompleted = false;
    mNewFrameAvailable = false;
    if (mLogVerbose)
        Log.v(TAG, "Setting up playback.");
    if (mMediaPlayer != null) {
        // Clean up existing media players
        if (mLogVerbose)
            Log.v(TAG, "Resetting existing MediaPlayer.");
        mMediaPlayer.reset();
    } else {
        // Create new media player
        if (mLogVerbose)
            Log.v(TAG, "Creating new MediaPlayer.");
        mMediaPlayer = new MediaPlayer();
    }
    if (mMediaPlayer == null) {
        throw new RuntimeException("Unable to create a MediaPlayer!");
    }
    // Set up data sources, etc
    try {
        if (useUrl) {
            if (mLogVerbose)
                Log.v(TAG, "Setting MediaPlayer source to URI " + mSourceUrl);
            if (mContext == null) {
                mMediaPlayer.setDataSource(mSourceUrl);
            } else {
                mMediaPlayer.setDataSource(mContext, Uri.parse(mSourceUrl.toString()));
            }
        } else {
            if (mLogVerbose)
                Log.v(TAG, "Setting MediaPlayer source to asset " + mSourceAsset);
            mMediaPlayer.setDataSource(mSourceAsset.getFileDescriptor(), mSourceAsset.getStartOffset(), mSourceAsset.getLength());
        }
    } catch (IOException e) {
        mMediaPlayer.release();
        mMediaPlayer = null;
        if (useUrl) {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
        } else {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
        }
    } catch (IllegalArgumentException e) {
        mMediaPlayer.release();
        mMediaPlayer = null;
        if (useUrl) {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
        } else {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
        }
    }
    mMediaPlayer.setLooping(mLooping);
    mMediaPlayer.setVolume(mVolume, mVolume);
    // Bind it to our media frame
    Surface surface = new Surface(mSurfaceTexture);
    mMediaPlayer.setSurface(surface);
    surface.release();
    // Connect Media Player to callbacks
    mMediaPlayer.setOnVideoSizeChangedListener(onVideoSizeChangedListener);
    mMediaPlayer.setOnPreparedListener(onPreparedListener);
    mMediaPlayer.setOnCompletionListener(onCompletionListener);
    // Connect SurfaceTexture to callback
    mSurfaceTexture.setOnFrameAvailableListener(onMediaFrameAvailableListener);
    if (mLogVerbose)
        Log.v(TAG, "Preparing MediaPlayer.");
    mMediaPlayer.prepareAsync();
    return true;
}
Also used : IOException(java.io.IOException) IllegalArgumentException(java.lang.IllegalArgumentException) MediaPlayer(android.media.MediaPlayer) Surface(android.view.Surface)

Example 29 with IllegalArgumentException

use of java.lang.IllegalArgumentException in project android_frameworks_base by ResurrectionRemix.

the class MediaSource method setupMediaPlayer.

/** Creates a media player, sets it up, and calls prepare */
private synchronized boolean setupMediaPlayer(boolean useUrl) {
    mPrepared = false;
    mGotSize = false;
    mPlaying = false;
    mPaused = false;
    mCompleted = false;
    mNewFrameAvailable = false;
    if (mLogVerbose)
        Log.v(TAG, "Setting up playback.");
    if (mMediaPlayer != null) {
        // Clean up existing media players
        if (mLogVerbose)
            Log.v(TAG, "Resetting existing MediaPlayer.");
        mMediaPlayer.reset();
    } else {
        // Create new media player
        if (mLogVerbose)
            Log.v(TAG, "Creating new MediaPlayer.");
        mMediaPlayer = new MediaPlayer();
    }
    if (mMediaPlayer == null) {
        throw new RuntimeException("Unable to create a MediaPlayer!");
    }
    // Set up data sources, etc
    try {
        if (useUrl) {
            if (mLogVerbose)
                Log.v(TAG, "Setting MediaPlayer source to URI " + mSourceUrl);
            if (mContext == null) {
                mMediaPlayer.setDataSource(mSourceUrl);
            } else {
                mMediaPlayer.setDataSource(mContext, Uri.parse(mSourceUrl.toString()));
            }
        } else {
            if (mLogVerbose)
                Log.v(TAG, "Setting MediaPlayer source to asset " + mSourceAsset);
            mMediaPlayer.setDataSource(mSourceAsset.getFileDescriptor(), mSourceAsset.getStartOffset(), mSourceAsset.getLength());
        }
    } catch (IOException e) {
        mMediaPlayer.release();
        mMediaPlayer = null;
        if (useUrl) {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
        } else {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
        }
    } catch (IllegalArgumentException e) {
        mMediaPlayer.release();
        mMediaPlayer = null;
        if (useUrl) {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
        } else {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
        }
    }
    mMediaPlayer.setLooping(mLooping);
    mMediaPlayer.setVolume(mVolume, mVolume);
    // Bind it to our media frame
    Surface surface = new Surface(mSurfaceTexture);
    mMediaPlayer.setSurface(surface);
    surface.release();
    // Connect Media Player to callbacks
    mMediaPlayer.setOnVideoSizeChangedListener(onVideoSizeChangedListener);
    mMediaPlayer.setOnPreparedListener(onPreparedListener);
    mMediaPlayer.setOnCompletionListener(onCompletionListener);
    // Connect SurfaceTexture to callback
    mSurfaceTexture.setOnFrameAvailableListener(onMediaFrameAvailableListener);
    if (mLogVerbose)
        Log.v(TAG, "Preparing MediaPlayer.");
    mMediaPlayer.prepareAsync();
    return true;
}
Also used : IOException(java.io.IOException) IllegalArgumentException(java.lang.IllegalArgumentException) MediaPlayer(android.media.MediaPlayer) Surface(android.view.Surface)

Example 30 with IllegalArgumentException

use of java.lang.IllegalArgumentException in project android_frameworks_base by crdroidandroid.

the class MediaSource method setupMediaPlayer.

/** Creates a media player, sets it up, and calls prepare */
private synchronized boolean setupMediaPlayer(boolean useUrl) {
    mPrepared = false;
    mGotSize = false;
    mPlaying = false;
    mPaused = false;
    mCompleted = false;
    mNewFrameAvailable = false;
    if (mLogVerbose)
        Log.v(TAG, "Setting up playback.");
    if (mMediaPlayer != null) {
        // Clean up existing media players
        if (mLogVerbose)
            Log.v(TAG, "Resetting existing MediaPlayer.");
        mMediaPlayer.reset();
    } else {
        // Create new media player
        if (mLogVerbose)
            Log.v(TAG, "Creating new MediaPlayer.");
        mMediaPlayer = new MediaPlayer();
    }
    if (mMediaPlayer == null) {
        throw new RuntimeException("Unable to create a MediaPlayer!");
    }
    // Set up data sources, etc
    try {
        if (useUrl) {
            if (mLogVerbose)
                Log.v(TAG, "Setting MediaPlayer source to URI " + mSourceUrl);
            if (mContext == null) {
                mMediaPlayer.setDataSource(mSourceUrl);
            } else {
                mMediaPlayer.setDataSource(mContext, Uri.parse(mSourceUrl.toString()));
            }
        } else {
            if (mLogVerbose)
                Log.v(TAG, "Setting MediaPlayer source to asset " + mSourceAsset);
            mMediaPlayer.setDataSource(mSourceAsset.getFileDescriptor(), mSourceAsset.getStartOffset(), mSourceAsset.getLength());
        }
    } catch (IOException e) {
        mMediaPlayer.release();
        mMediaPlayer = null;
        if (useUrl) {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
        } else {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
        }
    } catch (IllegalArgumentException e) {
        mMediaPlayer.release();
        mMediaPlayer = null;
        if (useUrl) {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
        } else {
            throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
        }
    }
    mMediaPlayer.setLooping(mLooping);
    mMediaPlayer.setVolume(mVolume, mVolume);
    // Bind it to our media frame
    Surface surface = new Surface(mSurfaceTexture);
    mMediaPlayer.setSurface(surface);
    surface.release();
    // Connect Media Player to callbacks
    mMediaPlayer.setOnVideoSizeChangedListener(onVideoSizeChangedListener);
    mMediaPlayer.setOnPreparedListener(onPreparedListener);
    mMediaPlayer.setOnCompletionListener(onCompletionListener);
    // Connect SurfaceTexture to callback
    mSurfaceTexture.setOnFrameAvailableListener(onMediaFrameAvailableListener);
    if (mLogVerbose)
        Log.v(TAG, "Preparing MediaPlayer.");
    mMediaPlayer.prepareAsync();
    return true;
}
Also used : IOException(java.io.IOException) IllegalArgumentException(java.lang.IllegalArgumentException) MediaPlayer(android.media.MediaPlayer) Surface(android.view.Surface)

Aggregations

IllegalArgumentException (java.lang.IllegalArgumentException)30 MediaPlayer (android.media.MediaPlayer)6 Surface (android.view.Surface)6 IOException (java.io.IOException)6 IndexOutOfBoundsException (java.lang.IndexOutOfBoundsException)4 RC2ParameterSpec (javax.crypto.spec.RC2ParameterSpec)2 ArrayIndexOutOfBoundsException (java.lang.ArrayIndexOutOfBoundsException)1 Integer (java.lang.Integer)1 NullPointerException (java.lang.NullPointerException)1 URI (java.net.URI)1 SimpleDateFormat (java.text.SimpleDateFormat)1 IvParameterSpec (javax.crypto.spec.IvParameterSpec)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 JobConf (org.apache.hadoop.mapred.JobConf)1