** 我真的需要帮助,如果你什么都不知道,请不要给我打分:|如果有什么事打扰你评论**
我想在 Exoplayer 中为我的播放器编写自定义 UI(更改暂停播放按钮或添加播放器速度等新按钮)。
我使用来自 github 的 Exoplayer 示例,在将代码添加到我的原始项目之前,我想在官方示例上测试自定义 UI。
我在 Stackoverflow 和 tuts+ 中阅读了有关自定义 UI 的页面,但我真的很困惑!
为什么更改一些按钮图像或更改它们的位置一定如此困难 :) 我该如何处理?
编辑
这是样本 https://github.com/google/ExoPlayer/tree/master/demo
我看了这两篇文章:
http://www.brightec.co.uk/ideas/custom-android-media-controller
http://code.tutsplus.com/tutorials/create-a-music-player-on-android-user-controls--mobile-22787
根据这个link “您可以从 Android 中包含的 MediaController 类开始,而不是从头开始编写您自己的媒体 Controller ”,我问这个问题是因为我无法在 exoplayer 库上执行此步骤,并且教程是为默认媒体播放器编写的
最佳答案
自定义 ExoPlayer 的 UI 非常简单。如果您查看 ExoPlayer 源代码,布局 res 目录包含文件 exo_player_control_view.xml,它指向(包括)另一个布局 - exo_playback_control_view。
exo_playback_control_view.xmlcustom_exo_playback_control_view.xml。将复制的内容粘贴到新的xml中PlayerView 的布局文件中指向自定义 exoPlayer UI 资源。这是我根据原始文件创建的 custom_exo_controller_view xml。我想要播放器控件的不同背景颜色以及不同的按钮和进度 View 颜色:
<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="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/attachment_document_desc_bg"
android:layoutDirection="ltr"
android:orientation="vertical"
android:paddingStart="20dp"
android:paddingEnd="20dp"
tools:targetApi="28">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="4dp">
<ImageButton
android:id="@id/exo_prev"
style="@style/ExoMediaButton.Previous"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_shuffle"
style="@style/ExoMediaButton.Shuffle"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_repeat_toggle"
style="@style/ExoMediaButton"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_play"
style="@style/ExoMediaButton.Play"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_pause"
style="@style/ExoMediaButton.Pause"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_next"
style="@style/ExoMediaButton.Next"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
<ImageButton
android:id="@id/exo_vr"
style="@style/ExoMediaButton.VR"
android:tint="@color/colorPrimaryDark"
android:tintMode="src_in" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@id/exo_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:textColor="#ff323232"
android:textSize="14sp"
android:textStyle="bold" />
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress"
android:layout_width="0dp"
android:layout_height="26dp"
android:layout_weight="1"
app:played_color="@color/colorPrimaryDark"
app:unplayed_color="@color/gray" />
<TextView
android:id="@id/exo_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:textColor="#ff323232"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
下面是我为播放器使用的代码。注意,xml 属性 app:controller_layout_id 指向上面定义的自定义 Controller View 。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
app:auto_show="true"
app:controller_layout_id="@layout/custom_exo_controller_view"
app:fastforward_increment="10000"
app:repeat_toggle_modes="none"
app:resize_mode="fixed_width"
app:rewind_increment="10000"
app:surface_type="surface_view"
app:use_controller="true" />
</FrameLayout>
这应该按照您想要的方式获得 UI。
您可以根据需要在自定义 Controller 和代码中添加额外的控件,使用 findViewById() 查找控件并编写事件监听器等。
关于android - exoplayer 示例上的自定义 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33647496/
我正在使用i18n从头开始构建一个多语言网络应用程序,虽然我自己可以处理一大堆yml文件,但我说的语言(非常)有限,最终我想寻求外部帮助帮助。我想知道这里是否有人在使用UI插件/gem(与django上的django-rosetta不同)来处理多个翻译器,其中一些翻译器不愿意或无法处理存储库中的100多个文件,处理语言数据。谢谢&问候,安德拉斯(如果您已经在rubyonrails-talk上遇到了这个问题,我们深表歉意) 最佳答案 有一个rails3branchofthetolkgem在github上。您可以通过在Gemfi
我正在尝试设置一个puppet节点,但rubygems似乎不正常。如果我通过它自己的二进制文件(/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter)在cli上运行facter,它工作正常,但如果我通过由rubygems(/usr/bin/facter)安装的二进制文件,它抛出:/usr/lib/ruby/1.8/facter/uptime.rb:11:undefinedmethod`get_uptime'forFacter::Util::Uptime:Module(NoMethodError)from/usr/lib/ruby
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
我想向我的Controller传递一个参数,它是一个简单的复选框,但我不知道如何在模型的form_for中引入它,这是我的观点:{:id=>'go_finance'}do|f|%>Transferirde:para:Entrada:"input",:placeholder=>"Quantofoiganho?"%>Saída:"output",:placeholder=>"Quantofoigasto?"%>Nota:我想做一个额外的复选框,但我该怎么做,模型中没有一个对象,而是一个要检查的对象,以便在Controller中创建一个ifelse,如果没有检查,请帮助我,非常感谢,谢谢
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
我有一些代码在几个不同的位置之一运行:作为具有调试输出的命令行工具,作为不接受任何输出的更大程序的一部分,以及在Rails环境中。有时我需要根据代码的位置对代码进行细微的更改,我意识到以下样式似乎可行:print"Testingnestedfunctionsdefined\n"CLI=trueifCLIdeftest_printprint"CommandLineVersion\n"endelsedeftest_printprint"ReleaseVersion\n"endendtest_print()这导致:TestingnestedfunctionsdefinedCommandLin
我有一个只接受一个参数的方法:defmy_method(number)end如果使用number调用方法,我该如何引发错误??通常,我如何定义方法参数的条件?比如我想在调用的时候报错:my_method(1) 最佳答案 您可以添加guard在函数的开头,如果参数无效则引发异常。例如:defmy_method(number)failArgumentError,"Inputshouldbegreaterthanorequalto2"ifnumbereputse.messageend#=>Inputshouldbegreaterthano