goCoder = WowzaGoCoder.init(getApplicationContext(), “GOSK-XXXX-XXXX-XXXX-XXXX-XXXX”);
<br> mStreamPlayerView = (WOWZPlayerView) findViewById(R.id.vwStreamPlayer);<br><br> // Create a configuration instance for the broadcasterfinal WOWZPlayerConfig mStreamPlayerConfig = new WOWZPlayerConfig();<br> mStreamPlayerConfig.setIsPlayback(true);<br>
//Below i have set credentials for live Stream<br> mStreamPlayerConfig.setHostAddress("");<br> mStreamPlayerConfig.setPortNumber(1935);<br> mStreamPlayerConfig.setApplicationName("");<br> mStreamPlayerConfig.setStreamName("");<br> mStreamPlayerConfig.setUsername("");<br> mStreamPlayerConfig.setPassword("");<br> mStreamPlayerConfig.setHLSEnabled(true);<br> mStreamPlayerConfig.setHLSBackupURL("");<br> mStreamPlayerConfig.setAudioEnabled(true);<br> mStreamPlayerConfig.setVideoEnabled(true);<br> mStreamPlayerView.setScaleMode(WOWZMediaConfig.FILL_VIEW);<br><br><br><br><br> new Handler().postDelayed(new Runnable() {<br> @Overridepublic void run() {<br> Log.e(TAG, "run: ");<br> Log.e(TAG, "run: "+mStreamPlayerView.isReadyToPlay() +" === "+mStreamPlayerView.isPlaying() );<br><br> if (mStreamPlayerView.isPlaying()) {<br> mStreamPlayerView.stop();<br> } else if (mStreamPlayerView.isReadyToPlay()) {<br> if (!isNetworkAvailable()) {<br> Log.e(TAG, "No internet connection, please try again later.");<br> return;<br> }<br><br><br> WOWZStreamingError configValidationError = mStreamPlayerConfig.validateForPlayback();<br> Log.e(TAG, "configValidationError: "+configValidationError );<br><br> if (configValidationError != null) {<br> Toast.makeText(PlayStreamActivity.this, configValidationError.getErrorDescription(), Toast.LENGTH_LONG).show();<br> } else {<br><br> // Start playback of the live streammStreamPlayerView.play(mStreamPlayerConfig, statusCallback);<br> }<br> }<br> }<br><br> }, 1000);<br>}<br> private boolean isNetworkAvailable() {<br> ConnectivityManager connectivityManager<br> = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);<br> NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();<br> return activeNetworkInfo != null && activeNetworkInfo.isConnected();<br> }<br><br>//// Methods implemented for the WOWZStatusCallback interface//// A successful status transition has been reported by the GoCoder SDKWOWZStatusCallback statusCallback = new WOWZStatusCallback() {<br> @Overridepublic void onWZStatus(WOWZStatus wowzStatus) {<br> switch (wowzStatus.getState()) {<br> case WOWZState.IDLE:<br> WOWZLog.info(TAG, "Streaming is not active");<br> break;<br><br> case WOWZState.STARTING:<br> WOWZLog.info(TAG, "Broadcast initialization");<br> break;<br><br> case WOWZState.READY:<br> WOWZLog.info(TAG, "Ready to begin streaming");<br> break;<br><br> case WOWZState.RUNNING:<br> WOWZLog.info(TAG, "Streaming is active");<br> break;<br><br> case WOWZState.STOPPING:<br> WOWZLog.info(TAG, "Broadcast shutdown");<br> break;<br> }<br> }<br><br> @Overridepublic void onWZError(final WOWZStatus wowzStatus) {<br><br><br> // Run this on the U/I threadnew Handler(Looper.getMainLooper()).post(new Runnable() {<br> @Overridepublic void run() {<br> String err = wowzStatus.getLastError().getErrorDescription();<br> Toast.makeText(getApplicationContext(),"Live Streaming Error: " + err+"", LENGTH_LONG).show();<br> }<br> });<br> }<br>};