当前位置: 首页>>代码示例>>Java>>正文


Java VideoView.setVideoPath方法代码示例

本文整理汇总了Java中android.widget.VideoView.setVideoPath方法的典型用法代码示例。如果您正苦于以下问题:Java VideoView.setVideoPath方法的具体用法?Java VideoView.setVideoPath怎么用?Java VideoView.setVideoPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.VideoView的用法示例。


在下文中一共展示了VideoView.setVideoPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Find the video view by id so we can use it.
    VideoView myVideo = (VideoView) findViewById(R.id.videoView);

    // To set the path to the video. Sample.mp4 is in the "raw" folder.
    // You can use http://online.path.to.your.video also.
    myVideo.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.sample);

    // To create the media controller (play, pause, etc.)
    MediaController myController = new MediaController(this);

    // To link the media controller to the video view.
    myController.setAnchorView(myVideo);

    // To link the video view to the media controller.
    myVideo.setMediaController(myController);

    // To autoplay on opening.
    myVideo.start();

}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:26,代码来源:MainActivity.java

示例2: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//强制竖屏
            final VideoView vv=new VideoView(this.getContext());
            RelativeLayout rlmain=new RelativeLayout(this.getContext());
            this.setContentView(vv);
            TextView txt=new TextView(rlmain.getContext());
            rlmain.addView(txt);
            txt.setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
//            rlmain.setBackgroundColor(Color.RED);
            vv.setVideoPath("/sdcard/mwwyt.mpg");
            vv.start();

            vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                    vv.start();
                }
            });


        }
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:26,代码来源:MainActivity.java

示例3: init

import android.widget.VideoView; //导入方法依赖的package包/类
private void init(String videoPath) {
    setContentView(R.layout.activity_trim);
    TextView duration = (TextView) findViewById(R.id.duration);
    mPreview = (VideoView) findViewById(R.id.preview);

    mShortVideoTrimmer = new PLShortVideoTrimmer(this, videoPath, Config.TRIM_FILE_PATH);
    mMediaFile = new PLMediaFile(videoPath);

    mSelectedEndMs = mDurationMs = mMediaFile.getDurationMs();
    duration.setText("时长: " + formatTime(mDurationMs));
    Log.i(TAG, "video duration: " + mDurationMs);

    mVideoFrameCount = mMediaFile.getVideoFrameCount(false);
    Log.i(TAG, "video frame count: " + mVideoFrameCount);

    mPreview.setVideoPath(videoPath);
    mPreview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            play();
        }
    });

    initVideoFrameList();
}
 
开发者ID:pili-engineering,项目名称:PLDroidShortVideo,代码行数:26,代码来源:VideoTrimActivity.java

示例4: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    VideoView videoView = new VideoView(this);
    setContentView(videoView);
    videoView.setMediaController(new MediaController(this));
    videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            Toast.makeText( VideoPlayerActivity.this, "播放完成了", Toast.LENGTH_SHORT).show();
        }
    });
    String videoPath = getIntent().getStringExtra("videoPath");
    try {
        videoView.setVideoPath(videoPath);
        videoView.start();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(VideoPlayerActivity.this, "视频不存在", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:mChenys,项目名称:AndroidFFmpegCompress,代码行数:22,代码来源:VideoPlayerActivity.java

示例5: go

import android.widget.VideoView; //导入方法依赖的package包/类
private void go() {
VideoView v=(VideoView)findViewById(R.id.videoView) ;
        final ProgressBar p=(ProgressBar)findViewById(R.id.progressBar3);
        v.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                p.setVisibility(View.GONE);
            }
        });
        String s="https://firebasestorage.googleapis.com/v0/b/lifesaver-18f28.appspot.com/o/flood.mp4?alt=media&token=179d7e4e-7171-4a87-b1f8-b1fc3d976c60";
        Uri uri=Uri.parse(s);
        v.setVideoURI(uri);
        v.setVideoPath(s);
        v.requestFocus();
        v.start();


    }
 
开发者ID:iamjaspreetsingh,项目名称:LifeSaver,代码行数:19,代码来源:Main4Activity.java

示例6: go

import android.widget.VideoView; //导入方法依赖的package包/类
private void go() {
        final ProgressBar p=(ProgressBar)findViewById(R.id.progressBar2);
        VideoView v=(VideoView)findViewById(R.id.videoView2) ;
v.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        p.setVisibility(View.GONE);
    }
});
String s="https://firebasestorage.googleapis.com/v0/b/lifesaver-18f28.appspot.com/o/earthquake.mp4?alt=media&token=98993371-823d-4b81-adc7-d9d87ec841a9";
        Uri uri=Uri.parse(s);
        v.setVideoURI(uri);
         v.setVisibility(View.VISIBLE);
         v.setVideoPath(s);
        v.requestFocus();
        v.start();





    }
 
开发者ID:iamjaspreetsingh,项目名称:LifeSaver,代码行数:23,代码来源:Main3Activity.java

示例7: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    mVideoPath = getIntent().getStringExtra("videoPath");

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    videoView = (VideoView) findViewById(R.id.view_video);

    android.widget.MediaController mediaController = new android.widget.MediaController(this);
    videoView.setMediaController(mediaController);
    videoView.setVideoPath(mVideoPath);
    videoView.start();
}
 
开发者ID:tryBetter,项目名称:minVideo,代码行数:19,代码来源:VideoActivity.java

示例8: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_play);

    enableLayoutFullScreen();

    mVideoView = (VideoView) findViewById(R.id.video_view);
    playView = (ImageView) findViewById(R.id.play_view);

    playView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playView.setVisibility(View.GONE);
            mVideoView.start();
        }
    });

    String videoPath = getIntent().getStringExtra(KEY_VIDEO_PATH);

    mVideoView.setVideoPath(videoPath);
    mVideoView.start();

    mVideoView.setOnCompletionListener(this);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:26,代码来源:VideoPlayActivity.java

示例9: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);

    // Load the appropriate URL in the VideoView.
    final String youtubeId = getIntent().getStringExtra(Keys.YOUTUBE_ID);
    final String videoUrl = UrlBuilder.forYoutubeId(youtubeId);
    final VideoView videoView = (VideoView) findViewById(R.id.video_view);
    videoView.setVideoPath(videoUrl);
    videoView.start();

    // Add a MediaController, which gives us play/pause, etc.
    final MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);
}
 
开发者ID:crm416,项目名称:android-lite,代码行数:18,代码来源:VideoActivity.java

示例10: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferencesState.getInstance().loadsLanguageInActivity();
    setContentView(R.layout.video_activity);

    //Displays a video file.
    MediaController mediaController = new MediaController(VideoActivity.this);
    mVideoView = (VideoView)findViewById(R.id.videoview);
    String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
    mVideoView.setVideoPath(videoPathParam);
    mVideoView.setMediaController(mediaController);
    mediaController.setAnchorView(mVideoView);

    mVideoView.requestFocus();
    if (savedInstanceState != null) {
        mVideoView.seekTo(savedInstanceState.getInt("video",0));
    }
    mVideoView.start();
}
 
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:21,代码来源:VideoActivity.java

示例11: onCreate

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferencesState.getInstance().initalizateActivityDependencies();
    setContentView(R.layout.video_activity);

    //Displays a video file.
    MediaController mediaController = new MediaController(VideoActivity.this);
    mVideoView = (VideoView) findViewById(R.id.videoview);
    String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
    File file = new File(videoPathParam);
    if (file.exists()) {
        mVideoView.setVideoPath(videoPathParam);
    } else {
        mVideoView.setVideoURI(FileIOUtils.getRawUri(videoPathParam));
    }
    mVideoView.setMediaController(mediaController);
    mediaController.setAnchorView(mVideoView);

    mVideoView.requestFocus();
    if (savedInstanceState != null) {
        mVideoView.seekTo(savedInstanceState.getInt("video", 0));
    }
    mVideoView.start();
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:26,代码来源:VideoActivity.java

示例12: loadVideoView

import android.widget.VideoView; //导入方法依赖的package包/类
/**
 * Loads the video specified by mediaPath into the given VideoView.
 *
 * Note that if the mediaPath is an asset or an URL, the video must be copied
 * to a temp file and then loaded from there. This could have performance
 * implications.
 *
 * @param videoView the VideoView
 * @param form the Form
 * @param mediaPath the path to the media
 */
public static void loadVideoView(VideoView videoView, Form form, String mediaPath)
    throws IOException {
  MediaSource mediaSource = determineMediaSource(form, mediaPath);
  switch (mediaSource) {
    case ASSET:
    case URL:
      File tempFile = cacheMediaTempFile(form, mediaPath, mediaSource);
      videoView.setVideoPath(tempFile.getAbsolutePath());
      return;

    case REPL_ASSET:
      videoView.setVideoPath(replAssetPath(mediaPath));
      return;

    case SDCARD:
      videoView.setVideoPath(mediaPath);
      return;

    case FILE_URL:
      videoView.setVideoPath(fileUrlToFilePath(mediaPath));
      return;

    case CONTENT_URI:
      videoView.setVideoURI(Uri.parse(mediaPath));
      return;

    case CONTACT_URI:
      throw new IOException("Unable to load video for contact " + mediaPath + ".");
  }
  throw new IOException("Unable to load video " + mediaPath + ".");
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:43,代码来源:MediaUtil.java

示例13: initViews

import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void initViews(Bundle savedInstanceState) {

    videoView = (VideoView) findViewById(R.id.view_video);
    android.widget.MediaController mediaController = new android.widget.MediaController(this);
    videoView.setMediaController(mediaController);

    File loopVideo = new File(LOOP_VIDEO_PATH);
    if(loopVideo.exists()){
        videoView.setVideoPath(LOOP_VIDEO_PATH);
        videoView.start();
    }else{
        Toast.makeText(this, "vendor.mp4 没有找到!", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:tryBetter,项目名称:minVideo,代码行数:16,代码来源:VideoMainActivity.java

示例14: init

import android.widget.VideoView; //导入方法依赖的package包/类
private void init() {
    //Authentication and authorization of App and SDK
    MemeLib.setAppClientID(getApplicationContext(), APP_ID, APP_SECRET);
    memeLib = MemeLib.getInstance();

    blinkLayout = (FrameLayout)findViewById(R.id.blink_layout);

    blinkImage = (ImageView)findViewById(R.id.blink_image);

    blinkView = (VideoView)findViewById(R.id.blink_view);
    blinkView.setZOrderOnTop(true);
    blinkView.setVideoPath("android.resource://" + this.getPackageName() + "/" + R.raw.blink);
    blinkView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            mediaPlayer.seekTo(0);
        }
    });

    bodyLayout = (FrameLayout)findViewById(R.id.body_layout);

    bodyImage = (ImageView)findViewById(R.id.body_image);

    statusLabel = (TextView)findViewById(R.id.status_label);

    connectButton = (Button)findViewById(R.id.connect_button);
    connectButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (memeLib.isConnected()) {
                memeLib.disconnect();
            } else {
                Intent intent = new Intent(LiveViewActivity.this, ConnectActivity.class);
                startActivity(intent);
            }
        }
    });

    changeViewStatus(memeLib.isConnected());
}
 
开发者ID:jins-meme,项目名称:JinsMemeSDK-Sample-Android,代码行数:41,代码来源:LiveViewActivity.java

示例15: loadVideoView

import android.widget.VideoView; //导入方法依赖的package包/类
/**
 * Loads the video specified by mediaPath into the given VideoView.
 *
 * Note that if the mediaPath is an asset or an URL, the video must be copied
 * to a temp file and then loaded from there. This could have performance
 * implications.
 *
 * @param videoView the VideoView
 * @param form the Form
 * @param mediaPath the path to the media
 */
public static void loadVideoView(VideoView videoView, FormService formservice, String mediaPath)
    throws IOException {
  MediaSource mediaSource = determineMediaSource(formservice, mediaPath);
  switch (mediaSource) {
    case ASSET:
    case URL:
      File tempFile = cacheMediaTempFile(formservice, mediaPath, mediaSource);
      videoView.setVideoPath(tempFile.getAbsolutePath());
      return;

    case REPL_ASSET:
      videoView.setVideoPath(replAssetPath(mediaPath));
      return;

    case SDCARD:
      videoView.setVideoPath(mediaPath);
      return;

    case FILE_URL:
      videoView.setVideoPath(fileUrlToFilePath(mediaPath));
      return;

    case CONTENT_URI:
      videoView.setVideoURI(Uri.parse(mediaPath));
      return;

    case CONTACT_URI:
      throw new IOException("Unable to load video for contact " + mediaPath + ".");
  }
  throw new IOException("Unable to load video " + mediaPath + ".");
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:43,代码来源:MediaUtilsvc.java


注:本文中的android.widget.VideoView.setVideoPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。