autoplay - I want to add auto play media in android -


i working on integrating video 1 of activities. plays fine, have click play play. searched forums , developer site , cannot find relating autoplay or autostart. suggestions?

mainactivity.java

...  protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);      floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab);     fab.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             snackbar.make(view, "replace own action", snackbar.length_long)                     .setaction("action", null).show();         }     });       videoview mvideoview = (videoview) findviewbyid(r.id.videoview);     mvideoview.setvideopath("file:///android_asset/video1.mp4");     mvideoview.setmediacontroller(new mediacontroller(this));     mvideoview.seekto(1);       //mvideoview.requestfocus(); } 

my contain_main.xml

<fragment 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:id="@+id/fragment"     android:name="imaker.mediaautoplay.mainactivityfragment"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior"     tools:layout="@layout/fragment_main">  <videoview     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/videoview"     android:layout_height="fill_parent"     android:layout_width="fill_parent" />  </fragment> 

mvideoview.start() start video

to start video

or can use

mvideoview.seekto(1) 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -