android videoview 上的进度条

发布于 2024-10-20 22:08:17 字数 263 浏览 6 评论 0原文

你好 我正在开发视频流应用程序,我需要在我的应用程序上制作一个进度条(不是进度对话框)我尝试实现它,我将它放在 xml 文件中并将其设置为 onprepared 方法上不可见,但问题是进度栏位于视频顶部,使视频尺寸变小 我需要让视频填充父级,进度条也像 YouTube 应用程序一样 我该怎么做?

另外我正在在线流媒体,所以当视频停止延迟时如何显示缓冲百分比

另一点是我希望当现在无法播放该视频的警报时进度条消失,但我不知道在哪里在代码中我应该消失进度条吗?此警报何时出现?

HI
i am developing video streaming application and i need to make a progress bar on my application (not a progress dialog) i tried implementing it i put it on the xml file and set it to invisible on the onprepared method but the problem is that the progress bar is placed on top of the video which makes the video size small
i need to make the video fill parent and the progress bar also like the youtube application
how can i do that ?

also i'm online streaming so how can i display the buffering percentage when the video is stopped for delay

another point is i want the progress bar to disappear when the alert of this video canot be played now ,, but i don't know where in the code i should disappear the progress bar ? when this alert appears ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无妨# 2024-10-27 22:08:17

我不确定 YouTube 的菜单是如何制作的,但您可以尝试 SlidingDrawer 并将您的 ProgressBar 嵌套在其中。

I'm not sure how YouTube does their menu, but you could try a SlidingDrawer and nest your ProgressBar in that.

秋叶绚丽 2024-10-27 22:08:17

看看这段代码,这可能对你有帮助。
该代码还包括必要的注释(如果需要)。

  public void videoPlayer(String path, String fileName, boolean autoplay){

      //get current window information, and set format, set it up differently, if you need some special effects

      getWindow().setFormat(PixelFormat.TRANSLUCENT);

      //the VideoView will hold the video

      VideoView videoHolder = new VideoView(this);

      //MediaController is the ui control howering above the video (just like in the default youtube player).

      videoHolder.setMediaController(new MediaController(this));

      //assing a video file to the video holder

      videoHolder.setVideoURI(Uri.parse(path+"/"+fileName));

      //get focus, before playing the video.

      videoHolder.requestFocus();

      if(autoplay){

          videoHolder.start();

      }

   }

谢谢...

look at this code, this might help you.
This code also include necessary comments , where ever needed.

  public void videoPlayer(String path, String fileName, boolean autoplay){

      //get current window information, and set format, set it up differently, if you need some special effects

      getWindow().setFormat(PixelFormat.TRANSLUCENT);

      //the VideoView will hold the video

      VideoView videoHolder = new VideoView(this);

      //MediaController is the ui control howering above the video (just like in the default youtube player).

      videoHolder.setMediaController(new MediaController(this));

      //assing a video file to the video holder

      videoHolder.setVideoURI(Uri.parse(path+"/"+fileName));

      //get focus, before playing the video.

      videoHolder.requestFocus();

      if(autoplay){

          videoHolder.start();

      }

   }

Thanks...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文