Android Open Source - GMIMediaAndroid Mutable Video View






From Project

Back to project page GMIMediaAndroid.

License

The source code is released under:

GNU General Public License

If you think the Android project GMIMediaAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2014 Gospel Ministries International
 *//from ww w . ja  va 2 s.  c  o m
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package com.gospelministries.gmimedia.widget;

import android.content.Context;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.util.AttributeSet;
import android.widget.VideoView;
//import android.widget.MediaController;

/**
 * TODO: implement
 *
 * @since 0.9_beta
 */
public class MutableVideoView extends VideoView implements OnPreparedListener,
    OnCompletionListener, OnErrorListener {

    private MediaPlayer mediaPlayer;

    public MutableVideoView(Context context, AttributeSet attributes) {
        super(context, attributes);

        this.setOnPreparedListener(this);
        this.setOnCompletionListener(this);
        this.setOnErrorListener(this);
    }

    @Override
    public void onPrepared(MediaPlayer mediaPlayer) {
        this.mediaPlayer = mediaPlayer;
    }

    @Override
    public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
        // TODO
        return false;
    }

    @Override
    public void onCompletion(MediaPlayer mediaPlayer) {
        // TODO
    }

    public void mute() {
        this.setVolume(0);
    }

    public void unmute() {
        this.setVolume(100);
    }

    // This can be declared public in order to gain full volume control
    private void setVolume(int amount) {
        final int max = 100;
        final double numerator = max - amount > 0 ? Math.log(max - amount) : 0;
        final float volume = (float) (1 - (numerator / Math.log(max)));

        this.mediaPlayer.setVolume(volume, volume);
    }
}




Java Source Code List

com.gospelministries.gmimedia.adapter.MainFragmentPagerAdapter.java
com.gospelministries.gmimedia.adapter.StreamArrayAdapter.java
com.gospelministries.gmimedia.bean.AudioStream.java
com.gospelministries.gmimedia.bean.StreamList.java
com.gospelministries.gmimedia.bean.Stream.java
com.gospelministries.gmimedia.bean.Streampoint.java
com.gospelministries.gmimedia.bean.VideoStream.java
com.gospelministries.gmimedia.ui.activity.AbstractStreamListFragment.java
com.gospelministries.gmimedia.ui.activity.InfoActivity.java
com.gospelministries.gmimedia.ui.activity.MainActivity.java
com.gospelministries.gmimedia.ui.activity.RadioListFragment.java
com.gospelministries.gmimedia.ui.activity.TvListFragment.java
com.gospelministries.gmimedia.ui.activity.VideoPlayerActivity.java
com.gospelministries.gmimedia.ui.dialog.SelectStreampointDialog.java
com.gospelministries.gmimedia.ui.dialog.TextFileDialogBuilder.java
com.gospelministries.gmimedia.util.Constants.java
com.gospelministries.gmimedia.util.SerializerHelper.java
com.gospelministries.gmimedia.widget.MutableVideoView.java
com.gospelministries.gmimedia.widget.MuteableVideoView.java