播放视频全屏 [英] playback video full screen

查看:35
本文介绍了播放视频全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用中播放视频.它必须被嵌入.

I am trying to play a video in my app. It has to be embedded.

我浏览了在 Android 中播放视频文件" 线程.

我可以使用这里提到的 VideoView 播放我的视频讨论.但是有几个问题.

I am able to play my video using VideoView as mentioned in this discussion. But there are a few problems.

  1. 我需要全屏视频,如何将 VideoView 拉伸到全屏?这也会拉伸视频吗?

  1. I need full screen video, how do I stretch VideoView to full screen? Will that stretch the video too?

我根本不需要默认的播放/前进/停止按钮.基本上我需要连续循环播放视频.

I don't need the default play/forward/stop buttons at all. Basically I need continuous loop playing of the video.

我尝试了 这里,但它从来没有奏效.如果我,字符串格式应该是什么样的在 res/raw 目录中有我的视频文件吗?我真的不想看视频从 sdcard 播放的文件.它如何与应用程序捆绑在一起?

I tried the MediaPlayer class as in here, but it never worked. What should the string format look like if I have my video file in res/raw directory? I really don't want the video file played from sdcard. How can it be bundled along with the app?

如果这两种方法中的任何一种有效,我都会过得更好.

If any of these two approaches work, I will be better off.

这是我的代码:

videoHolder = new VideoView(this); 
// videoHolder = (VideoView)findViewById(R.id.videoview); 
LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 
videoHolder.setLayoutParams(params); 
videoHolder.setMediaController(new MediaController(this)); 
setContentView(videoHolder); 
// 
// 
//// I tested and found that it works fine for .wmv, .3gp and .mp4 
//// videoHolder.setVideoURI(Uri.parse("file:///sdcard/video.3gp")); 
videoHolder.setVideoURI(Uri.parse("res/raw/demo.3gp")); 
videoHolder.requestFocus(); 
videoHolder.start(); 

奇怪的是,注释的 url 有效(带有 sdcard 的那个).另一个不起作用.我已经尝试了许多来自file://"的组合res/raw/demo.3gp"到只有演示".

Strangely the commented url works (the one with sdcard). The other one does not work. I have tried many combinations from "file:// res/raw/demo.3gp" to only "demo".

访问文件的正确字符串是什么?

What would be the correct string to access the file?

推荐答案

播放视频到全屏模式无需任何编码

No need to do any coding for playing video to full screen mode

在包含视频视图的 xml 上应用以下布局格式,它肯定会以全屏模式播放视频.因为它正在运行我的.

Apply the following layout format over the xml containing the videoview it will for sure will play the video in full screen mode. as it is running mine.

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>

加上添加 mediacontroller 也会为您提供要使用的控制器.

Plus adding the mediacontroller will also give you the controller to use.

这篇关于播放视频全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆