I am developing a phonegap application which has a VideoView screen to play audio (Coming from Wowza streaming engine). My issue is that, I want to play audio instantly when VideoView gets loaded on the screen. What currently is happening in my app, When my VideoView gets loaded It does not even show up on the screen (It shows up when I touch the screen, This is another issue).
Now when it appears on the screen on touch, I have to click on the play button to start playing the audio. (I am using libstreaming library)
Here is my code-
activity_main.xml
<io.vov.vitamio.widget.VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:visibility="visible"
/>
Activity Class:
private VideoView mVideoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
if (!LibsChecker.checkVitamioLibs(this))
return;
mVideoView = (VideoView) findViewById(R.id.video_view);
mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
mVideoView.getHolder().setFormat(PixelFormat.RGBX_8888);
startRtmpStream();
}
public void startRtmpStream() {
mVideoView.setVideoPath(AppConfig.STREAM_URL_AUDIO_ONLY);
mVideoView.setMediaController(new MediaController(this));
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
mVideoView.start();
}
AppConfig.java
public class AppConfig {
public static final String STREAM_URL_AUDIO_ONLY = "rtmp://10.101.3.129:1935/app1/myStream";
public static final String PUBLISHER_USERNAME = "";
public static final String PUBLISHER_PASSWORD = "";}