最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android實(shí)現(xiàn)播放網(wǎng)絡(luò)視頻

 更新時(shí)間:2021年04月16日 10:21:28   作者:Jackie·Tang  
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)播放網(wǎng)絡(luò)視頻,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了android實(shí)現(xiàn)播放網(wǎng)絡(luò)視頻的具體代碼,供大家參考,具體內(nèi)容如下

PlayVideoActivity.java

package cn.edu.zufe.app002;

import android.Manifest;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.widget.VideoView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class PlayVideoActivity extends AppCompatActivity implements View.OnClickListener{

    private VideoView vvVideo;
    private Button btnPlay;
    private Button btnPause;
    private Button btnReplay;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_video);

        vvVideo = (VideoView) findViewById(R.id.vv_video);
        btnPlay = (Button) findViewById(R.id.btn_play);
        btnPause = (Button) findViewById(R.id.btn_pause);
        btnReplay = (Button) findViewById(R.id.btn_replay);

        btnPlay.setOnClickListener(this);
        btnPause.setOnClickListener(this);
        btnReplay.setOnClickListener(this);

        if(ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
        } else {
            initVideoView();
        }
    }

    private void initVideoView() {
        vvVideo.setVideoPath("http://jackie.vaiwan.com/cn.edu.zufe.app002/zhecai.mp4");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_play:
                if(!vvVideo.isPlaying()) {
                    vvVideo.start();
                }
                break;
            case R.id.btn_pause:
                if(vvVideo.isPlaying()) {
                    vvVideo.pause();
                }
                break;
            case R.id.btn_replay:
                if(vvVideo.isPlaying()) {
                    vvVideo.resume();
                }
                break;
            default:
                break;
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        switch (requestCode) {
            case 1:
                if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    initVideoView();
                } else {
                    Toast.makeText(this, "沒(méi)有足夠的權(quán)限", Toast.LENGTH_SHORT).show();
                    finish();
                }
        }
    }
}

activity_play_video.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".PlayVideoActivity">

    <VideoView
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:id="@+id/vv_video" />
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="播放"
            android:id="@+id/btn_play" />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="暫停"
            android:id="@+id/btn_pause" />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="重播"
            android:id="@+id/btn_replay" />

    </LinearLayout>

</LinearLayout>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 詳解Flutter中的數(shù)據(jù)傳遞

    詳解Flutter中的數(shù)據(jù)傳遞

    這篇文章主要介紹了Flutter中的數(shù)據(jù)傳遞的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用Flutter,感興趣的朋友可以了解下
    2021-04-04
  • Android開(kāi)發(fā)中常見(jiàn)問(wèn)題

    Android開(kāi)發(fā)中常見(jiàn)問(wèn)題

    這篇文章主要為大家詳細(xì)介紹了Android開(kāi)發(fā)中常見(jiàn)問(wèn)題,主要涉及了七個(gè)問(wèn)題,希望能幫助到大家,感興趣的小伙伴們可以參考一下
    2016-06-06
  • Android解決所有雙擊優(yōu)化的問(wèn)題

    Android解決所有雙擊優(yōu)化的問(wèn)題

    這篇文章主要為大家介紹了Android解決所有雙擊優(yōu)化的問(wèn)題,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Android Studio多渠道打包的配置方法

    Android Studio多渠道打包的配置方法

    今天小編就為大家分享一篇關(guān)于Android Studio多渠道打包的配置方法,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-12-12
  • Android Studio實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車(chē)功能

    Android Studio實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車(chē)功能

    這篇文章主要為大家詳細(xì)介紹了Android Studio實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車(chē),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android使用MediaRecorder實(shí)現(xiàn)錄像功能

    Android使用MediaRecorder實(shí)現(xiàn)錄像功能

    這篇文章主要為大家詳細(xì)介紹了Android使用MediaRecorder實(shí)現(xiàn)錄像功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • 詳解Android端與JavaWeb傳輸加密(DES+RSA)

    詳解Android端與JavaWeb傳輸加密(DES+RSA)

    這篇文章主要介紹了詳解Android端與JavaWeb傳輸加密(DES+RSA),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-11-11
  • Android中Dialog的使用詳解

    Android中Dialog的使用詳解

    Dialog(對(duì)話框)是Android中常用的UI組件,用于臨時(shí)顯示重要信息或獲取用戶(hù)輸入,本文給大家介紹Android中Dialog的使用,感興趣的朋友一起看看吧
    2025-04-04
  • Android實(shí)現(xiàn) Shape屬性gradient 漸變效果

    Android實(shí)現(xiàn) Shape屬性gradient 漸變效果

    這篇文章主要介紹了Android 實(shí)現(xiàn)Shape屬性gradient 漸變效果,gradient用以定義漸變色,可以定義兩色漸變和三色漸變,及漸變樣式,具體實(shí)現(xiàn)代碼感興趣的朋友跟隨小編一起看看吧
    2019-11-11
  • android實(shí)現(xiàn)可自由移動(dòng)、監(jiān)聽(tīng)點(diǎn)擊事件的懸浮窗

    android實(shí)現(xiàn)可自由移動(dòng)、監(jiān)聽(tīng)點(diǎn)擊事件的懸浮窗

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)可自由移動(dòng)、監(jiān)聽(tīng)點(diǎn)擊事件的懸浮窗,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-12-12

最新評(píng)論

胶南市| 西城区| 灵台县| 湘潭市| 济阳县| 宁晋县| 景泰县| 集贤县| 中卫市| 罗城| 轮台县| 昌吉市| 凤台县| 长白| 岐山县| 华容县| 桐乡市| 周宁县| 沙雅县| 全南县| 星子县| 拜泉县| 武清区| 察哈| 青田县| 汝阳县| 若羌县| 宣汉县| 南通市| 墨玉县| 京山县| 随州市| 双鸭山市| 湘潭县| 奇台县| 临朐县| 二连浩特市| 涡阳县| 思茅市| 治县。| 盘山县|