Search in sources :

Example 31 with VideoView

use of android.widget.VideoView in project android_packages_apps_Settings by crdroidandroid.

the class ToggleScreenMagnificationPreferenceFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    VideoView videoView = (VideoView) getView().findViewById(R.id.video);
    if (videoView != null) {
        videoView.start();
    }
    updateConfigurationWarningIfNeeded();
}
Also used : VideoView(android.widget.VideoView)

Example 32 with VideoView

use of android.widget.VideoView in project ABPlayer by winkstu.

the class MainActivity method findViews.

private void findViews() {
    mMediaController = findViewById(R.id.media_controller);
    mBtnRotate = (Button) findViewById(R.id.rotate);
    mBtnHideDanmaku = (Button) findViewById(R.id.btn_hide);
    mBtnShowDanmaku = (Button) findViewById(R.id.btn_show);
    mBtnPauseDanmaku = (Button) findViewById(R.id.btn_pause);
    mBtnResumeDanmaku = (Button) findViewById(R.id.btn_resume);
    mBtnSendDanmaku = (Button) findViewById(R.id.btn_send);
    mBtnSendDanmakus = (Button) findViewById(R.id.btn_send_danmakus);
    mBtnRotate.setOnClickListener(this);
    mBtnHideDanmaku.setOnClickListener(this);
    mMediaController.setOnClickListener(this);
    mBtnShowDanmaku.setOnClickListener(this);
    mBtnPauseDanmaku.setOnClickListener(this);
    mBtnResumeDanmaku.setOnClickListener(this);
    mBtnSendDanmaku.setOnClickListener(this);
    mBtnSendDanmakus.setOnClickListener(this);
    // VideoView
    VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
    // DanmakuView
    mDanmakuView = (IDanmakuView) findViewById(R.id.sv_danmaku);
    DanmakuGlobalConfig.DEFAULT.setDanmakuStyle(DanmakuGlobalConfig.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false);
    if (mDanmakuView != null) {
        mParser = createParser(this.getResources().openRawResource(R.raw.comments));
        mDanmakuView.setCallback(new Callback() {

            @Override
            public void updateTimer(DanmakuTimer timer) {
            }

            @Override
            public void prepared() {
                mDanmakuView.start();
            }
        });
        mDanmakuView.prepare(mParser);
        mDanmakuView.showFPS(true);
        mDanmakuView.enableDanmakuDrawingCache(true);
        ((View) mDanmakuView).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                mMediaController.setVisibility(View.VISIBLE);
            }
        });
    }
    if (mVideoView != null) {
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.start();
            }
        });
        // mVideoView.setVideoPath(Environment.getExternalStorageDirectory() + "/1.flv");
        mVideoView.setVideoURI(Uri.parse("http://us-chicago.acgvideo.com/e/e9/3444659.mp4?expires=1429119900&ssig=o8fAECKGmZkIsdZE31EYOQ&o=401361084&rate=0"));
    }
}
Also used : Callback(master.flame.danmaku.controller.DrawHandler.Callback) VideoView(android.widget.VideoView) DanmakuTimer(master.flame.danmaku.danmaku.model.DanmakuTimer) View(android.view.View) VideoView(android.widget.VideoView) DanmakuSurfaceView(master.flame.danmaku.ui.widget.DanmakuSurfaceView) IDanmakuView(master.flame.danmaku.controller.IDanmakuView) MediaPlayer(android.media.MediaPlayer)

Example 33 with VideoView

use of android.widget.VideoView in project DanmakuFlameMaster by Bilibili.

the class UglyViewCacheStufferSampleActivity method findViews.

private void findViews() {
    mMediaController = findViewById(R.id.media_controller);
    mBtnRotate = (Button) findViewById(R.id.rotate);
    mBtnHideDanmaku = (Button) findViewById(R.id.btn_hide);
    mBtnShowDanmaku = (Button) findViewById(R.id.btn_show);
    mBtnPauseDanmaku = (Button) findViewById(R.id.btn_pause);
    mBtnResumeDanmaku = (Button) findViewById(R.id.btn_resume);
    mBtnSendDanmaku = (Button) findViewById(R.id.btn_send);
    mBtnSendDanmakuTextAndImage = (Button) findViewById(R.id.btn_send_image_text);
    mBtnSendDanmakus = (Button) findViewById(R.id.btn_send_danmakus);
    mBtnRotate.setOnClickListener(this);
    mBtnHideDanmaku.setOnClickListener(this);
    mMediaController.setOnClickListener(this);
    mBtnShowDanmaku.setOnClickListener(this);
    mBtnPauseDanmaku.setOnClickListener(this);
    mBtnResumeDanmaku.setOnClickListener(this);
    mBtnSendDanmaku.setOnClickListener(this);
    mBtnSendDanmakuTextAndImage.setOnClickListener(this);
    mBtnSendDanmakus.setOnClickListener(this);
    // VideoView
    VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
    // DanmakuView
    // 设置最大显示行数
    HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
    // 滚动弹幕最大显示5行
    maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 5);
    // 设置是否禁止重叠
    HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<Integer, Boolean>();
    overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
    overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);
    mDanmakuView = (IDanmakuView) findViewById(R.id.sv_danmaku);
    mContext = DanmakuContext.create();
    mIconWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30f, getResources().getDisplayMetrics());
    mContext.setDanmakuBold(true);
    mContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false).setScrollSpeedFactor(1.2f).setScaleTextSize(1.2f).setCacheStuffer(new ViewCacheStuffer<MyViewHolder>() {

        @Override
        public MyViewHolder onCreateViewHolder(int viewType) {
            Log.e("DFM", "onCreateViewHolder:" + viewType);
            return new MyViewHolder(View.inflate(getApplicationContext(), R.layout.layout_view_cache, null));
        }

        @Override
        public void onBindViewHolder(int viewType, MyViewHolder viewHolder, BaseDanmaku danmaku, AndroidDisplayer.DisplayerConfig displayerConfig, TextPaint paint) {
            if (paint != null)
                viewHolder.mText.getPaint().set(paint);
            viewHolder.mText.setText(danmaku.text);
            viewHolder.mText.setTextColor(danmaku.textColor);
            viewHolder.mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, danmaku.textSize);
            Bitmap bitmap = null;
            MyImageWare imageWare = (MyImageWare) danmaku.tag;
            if (imageWare != null) {
                bitmap = imageWare.bitmap;
                if (danmaku.text.toString().contains("textview")) {
                    Log.e("DFM", "onBindViewHolder======> bitmap:" + (bitmap == null) + "  " + danmaku.tag + "url:" + imageWare.getImageUri());
                }
            }
            if (bitmap != null) {
                viewHolder.mIcon.setImageBitmap(bitmap);
                if (danmaku.text.toString().contains("textview")) {
                    Log.e("DFM", "onBindViewHolder======>" + danmaku.tag + "url:" + imageWare.getImageUri());
                }
            } else {
                viewHolder.mIcon.setImageResource(R.drawable.ic_launcher);
            }
        }

        @Override
        public void releaseResource(BaseDanmaku danmaku) {
            MyImageWare imageWare = (MyImageWare) danmaku.tag;
            if (imageWare != null) {
                ImageLoader.getInstance().cancelDisplayTask(imageWare);
            }
            danmaku.setTag(null);
            Log.e("DFM", "releaseResource url:" + danmaku.text);
        }

        String[] avatars = { "http://i0.hdslb.com/bfs/face/e13fcb94342c325debb2d3a1d9e503ac4f083514.jpg@45w_45h.webp", "http://i0.hdslb.com/bfs/bangumi/2558e1341d2e934a7e06bb7d92551fef5c82c172.jpg@72w_72h.webp", "http://i0.hdslb.com/bfs/face/128edefeef7ce9cfc443a2489d8a1c7d44d88b80.jpg@72w_72h.webp" };

        @Override
        public void prepare(BaseDanmaku danmaku, boolean fromWorkerThread) {
            if (danmaku.isTimeOut()) {
                return;
            }
            MyImageWare imageWare = (MyImageWare) danmaku.tag;
            if (imageWare == null) {
                String avatar = avatars[danmaku.index % avatars.length];
                imageWare = new MyImageWare(avatar, danmaku, mIconWidth, mIconWidth, mDanmakuView);
                danmaku.setTag(imageWare);
            }
            if (danmaku.text.toString().contains("textview")) {
                Log.e("DFM", "onAsyncLoadResource======>" + danmaku.tag + "url:" + imageWare.getImageUri());
            }
            ImageLoader.getInstance().displayImage(imageWare.getImageUri(), imageWare);
        }
    }, // 图文混排使用SpannedCacheStuffer
    null).setMaximumLines(maxLinesPair).preventOverlapping(overlappingEnablePair);
    if (mDanmakuView != null) {
        mParser = createParser(this.getResources().openRawResource(R.raw.comments));
        mDanmakuView.setCallback(new master.flame.danmaku.controller.DrawHandler.Callback() {

            @Override
            public void updateTimer(DanmakuTimer timer) {
            }

            @Override
            public void drawingFinished() {
            }

            @Override
            public void danmakuShown(BaseDanmaku danmaku) {
            // Log.d("DFM", "danmakuShown(): text=" + danmaku.text);
            }

            @Override
            public void prepared() {
                mDanmakuView.start();
            }
        });
        mDanmakuView.setOnDanmakuClickListener(new IDanmakuView.OnDanmakuClickListener() {

            @Override
            public boolean onDanmakuClick(IDanmakus danmakus) {
                Log.d("DFM", "onDanmakuClick: danmakus size:" + danmakus.size());
                BaseDanmaku latest = danmakus.last();
                if (null != latest) {
                    Log.d("DFM", "onDanmakuClick: text of latest danmaku:" + latest.text);
                    return true;
                }
                return false;
            }

            @Override
            public boolean onDanmakuLongClick(IDanmakus danmakus) {
                return false;
            }

            @Override
            public boolean onViewClick(IDanmakuView view) {
                mMediaController.setVisibility(View.VISIBLE);
                return false;
            }
        });
        mDanmakuView.prepare(mParser, mContext);
        mDanmakuView.showFPS(true);
        mDanmakuView.enableDanmakuDrawingCache(true);
    }
    if (mVideoView != null) {
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.start();
            }
        });
        mVideoView.setVideoPath(Environment.getExternalStorageDirectory() + "/1.flv");
    }
}
Also used : HashMap(java.util.HashMap) VideoView(android.widget.VideoView) Bitmap(android.graphics.Bitmap) BaseDanmaku(master.flame.danmaku.danmaku.model.BaseDanmaku) DanmakuTimer(master.flame.danmaku.danmaku.model.DanmakuTimer) IDanmakus(master.flame.danmaku.danmaku.model.IDanmakus) AndroidDisplayer(master.flame.danmaku.danmaku.model.android.AndroidDisplayer) IDanmakuView(master.flame.danmaku.controller.IDanmakuView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) MediaPlayer(android.media.MediaPlayer)

Example 34 with VideoView

use of android.widget.VideoView in project android_packages_apps_Settings by SudaMod.

the class ToggleScreenMagnificationPreferenceFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    VideoView videoView = (VideoView) getView().findViewById(R.id.video);
    if (videoView != null) {
        videoView.start();
    }
    updateConfigurationWarningIfNeeded();
}
Also used : VideoView(android.widget.VideoView)

Example 35 with VideoView

use of android.widget.VideoView in project NewPipe by TeamNewPipe.

the class PlayVideoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_video);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    // set background arrow style
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp);
    isLandscape = checkIfLandscape();
    hasSoftKeys = checkIfHasSoftKeys();
    actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    if (mediaController == null) {
        // prevents back button hiding media controller controls (after showing them)
        // instead of exiting video
        // see http://stackoverflow.com/questions/6051825
        // also solves https://github.com/theScrabi/NewPipe/issues/99
        mediaController = new MediaController(this) {

            @Override
            public boolean dispatchKeyEvent(KeyEvent event) {
                int keyCode = event.getKeyCode();
                final boolean uniqueDown = event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN;
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    if (uniqueDown) {
                        if (isShowing()) {
                            finish();
                        } else {
                            hide();
                        }
                    }
                    return true;
                }
                return super.dispatchKeyEvent(event);
            }
        };
    }
    // convert from seconds to milliseconds
    position = intent.getIntExtra(START_POSITION, 0) * 1000;
    videoView = findViewById(R.id.video_view);
    progressBar = findViewById(R.id.play_video_progress_bar);
    try {
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(Uri.parse(intent.getStringExtra(STREAM_URL)));
    } catch (Exception e) {
        e.printStackTrace();
    }
    videoView.requestFocus();
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            progressBar.setVisibility(View.GONE);
            videoView.seekTo(position);
            if (position <= 0) {
                videoView.start();
                showUi();
            } else {
                videoView.pause();
            }
        }
    });
    videoUrl = intent.getStringExtra(VIDEO_URL);
    Button button = findViewById(R.id.content_button);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (uiIsHidden) {
                showUi();
            } else {
                hideUi();
            }
        }
    });
    decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if (visibility == View.VISIBLE && uiIsHidden) {
                showUi();
            }
        }
    });
    if (android.os.Build.VERSION.SDK_INT >= 17) {
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }
    prefs = getPreferences(Context.MODE_PRIVATE);
    if (prefs.getBoolean(PREF_IS_LANDSCAPE, false) && !isLandscape) {
        toggleOrientation();
    }
}
Also used : KeyEvent(android.view.KeyEvent) MediaController(android.widget.MediaController) Button(android.widget.Button) Intent(android.content.Intent) View(android.view.View) VideoView(android.widget.VideoView) MediaPlayer(android.media.MediaPlayer)

Aggregations

VideoView (android.widget.VideoView)44 View (android.view.View)25 MediaPlayer (android.media.MediaPlayer)13 TextView (android.widget.TextView)12 FrameLayout (android.widget.FrameLayout)10 ImageView (android.widget.ImageView)9 Uri (android.net.Uri)8 Button (android.widget.Button)7 Bitmap (android.graphics.Bitmap)6 LinearLayout (android.widget.LinearLayout)6 MediaController (android.widget.MediaController)6 Intent (android.content.Intent)5 WebView (android.webkit.WebView)5 MotionEvent (android.view.MotionEvent)3 OnClickListener (android.view.View.OnClickListener)3 AdapterView (android.widget.AdapterView)3 FileOutputStream (java.io.FileOutputStream)3 KeyEvent (android.view.KeyEvent)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 HorizontalScrollView (android.widget.HorizontalScrollView)2