一個Android上的彈幕控制項Open Danmaku

來源:互聯網
上載者:User

標籤:

彈幕現在很流行,特別是在視頻播放時,安卓上沒有簡單好用的彈幕控制項,於是自己寫了一個.

項目地址:https://github.com/linsea/OpenDanmaku
或者國內開源中國上的鏡像:http://git.oschina.net/dictfb/OpenDanmaku


使用方法

完整的使用方法請查看項目的Demo.

1. 在build.gradle檔案中加入依賴.

dependencies {    compile ‘com.linsea:opendanmaku:[email protected]‘ }

2. 在布局檔案中加入自訂的彈幕View.
<com.opendanmaku.DanmakuView        android:id="@+id/danmakuView"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        app:start_Y_offset="0.2"        app:end_Y_offset="0.8"        app:max_row="4"        app:max_running_per_row="2"        app:pick_interval="1000"        app:show_debug="false" />

3. 在Activity中產生彈幕對象,並加入到播放清單中.
mDanmakuView = (DanmakuView) findViewById(R.id.danmakuView);// add danmaku items:mDanmakuView.addItem(list, true);mDanmakuView.addItem(new DanmakuItem(this, "Hello World", mDanmakuView.getWidth());//show danmaku and play animation:mDanmakuView.show();//hide and pause playing:mDanmakuView.hide();//release all playing and waiting items:mDanmakuView.clear();

DanmakuView的自訂屬性


 * start_Y_offset

第一條播放航道距離彈幕View上邊緣的位移量,注意值是百分比量,以彈幕View的高度為基準,簡而言之就是彈幕View的上邊緣空出多少百分比.

 * end_Y_offset

與上一個屬性類似,最後一條播放航道距離彈幕View上邊緣的位移量,注意值是百分比量,以彈幕View的高度為基準,主要作用是便於在彈幕View的底部留出一定的空白.

 * max_row

設定最多多少條播放航道.

 * max_running_per_row

每條航道上最多同時有多少條彈幕運行.

 * pick_interval 

每隔多少毫秒取出一條彈幕來播放.

 * show_debug 

是否顯示航道線及播放幀率,調試時很有用,主要用於調試.


一個Android上的彈幕控制項Open Danmaku

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.