今天教大家弄背景图片或者背景视频
背景视频所需代码:
import
“android.media.MediaPlayer”—导入
—放在main.lua↓
▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂
视频控件id.setVideoPath((activity.getLuaDir()..”/Xc/Xc.mp4″))–视频路径
视频控件id.start()
–监听视频缓冲完成事件
视频控件id.setOnPreparedListener(MediaPlayer.OnPreparedListener{
onPrepared=function(视频循环)
视频控件id.start()–播放
视频循环.setLooping(true)–循环播放
end
});
▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂
—视频布局
▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂
{
LinearLayout;
orientation=”vertical”;
layout_width=”fill”;
layout_height=”fill”;
{
FrameLayout;
layout_width=”fill”;
layout_height=”fill”;
{
VideoView;
id=”视频”;—视频控件id
layout_height=”match_parent”;
layout_width=”wrap_content”;
};
—如果没有按钮的布局,只要一个视频的布局直接在在下面加两行
};
▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂▂_▂_▂_▂_▂_▂_▂_▂▂_▂_▂▂_▂_▂▂_▂



