• 播放网络视频


    播放网络视频:

    PlayInternetVideoActivity.java

    package com.example.videoplaydemo;
    
    import android.app.Activity;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;
    
    import java.io.File;
    
    import android.app.Activity;
    
    import android.os.Bundle;
    
    import android.view.View;
    
    import android.view.View.OnClickListener;
    
    import android.widget.MediaController;
    
    import android.widget.Toast;
    
    import android.widget.VideoView;
    
    import java.io.File;
    
    import android.app.Activity;
    
    import android.media.MediaPlayer;
    
    import android.media.MediaPlayer.OnCompletionListener;
    
    import android.media.MediaPlayer.OnErrorListener;
    
    import android.os.Bundle;
    
    import android.util.Log;
    
    import android.view.View;
    
    import android.widget.Button;
    
    import android.widget.EditText;
    
    import android.widget.SeekBar;
    
    import android.widget.Toast;
    
    import android.widget.VideoView;
    
    import android.widget.SeekBar.OnSeekBarChangeListener;
    
    public class PlayInternetVideoActivity extends Activity {
    
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    
    		// TODO Auto-generated method stub
    
    		super.onCreate(savedInstanceState);
    
    		setContentView(R.layout.acticity_play_internet_video);
    
    		   Uri uri = Uri.parse("http://120.24.84.74:8086/data/image/gold/video/yaoqianshu.mp4");  
     	       VideoView videoView = (VideoView)this.findViewById(R.id.vv_videoview);  
     	       videoView.setMediaController(new MediaController(this));  
     	       videoView.setVideoURI(uri);  
     	       videoView.start();  
               videoView.requestFocus();  
    
    	}
    
    	
    }
    

    xml 文件:

    <?xml version="1.0" encoding="utf-8"?>
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    
        android:layout_width="match_parent"
    
        android:layout_height="match_parent"
    
        android:orientation="vertical" >
    
       
        
    
        <VideoView
    
            android:id="@+id/vv_videoview"
    
            android:layout_width="300dp"
    
            android:layout_height="300dp" />
    
        
    
    </LinearLayout>
    

    关键点:

    无法播放此视频

      <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

  • 相关阅读:
    SSH免密码登陆备忘
    WeiBo官网oauth2开发文档理解
    TOP
    使用定位,逆地理编码,经纬度《=转=》地址信息、逆地理编码,地址《=转=》经纬度,贼方便!!!!
    计算机病毒分类之感染目标
    预处理
    指针与引用
    printf问题参数顺序
    神奇的求平均数
    C和C++的关系
  • 原文地址:https://www.cnblogs.com/childhooding/p/4461468.html
Copyright © 2020-2023  润新知