Error is on
***********************************************************************************
public void onWZStatus(final WOWZBroadcastStatus goCoderStatus) {
// A successful status transition has been reported by the GoCoder SDK
final StringBuffer statusMessage = new StringBuffer("Broadcast status: ");
switch (goCoderStatus.getState()) {
case BroadcastState.READY:
statusMessage.append("Ready to begin broadcasting");
break;
case BroadcastState.BROADCASTING:
statusMessage.append("Broadcast is active");
break;
case BroadcastState.IDLE:
statusMessage.append("The broadcast is stopped");
break;
default:
return;
}
// Display the status message using the U/I thread
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, statusMessage, Toast.LENGTH_LONG).show();
}
});
}
package com.example.livestreamtest;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.wowza.gocoder.sdk.api.WowzaGoCoder;
import com.wowza.gocoder.sdk.api.broadcast.WOWZBroadcast;
import com.wowza.gocoder.sdk.api.broadcast.WOWZBroadcastConfig;
import com.wowza.gocoder.sdk.api.configuration.WOWZMediaConfig;
import com.wowza.gocoder.sdk.api.devices.WOWZAudioDevice;
import com.wowza.gocoder.sdk.api.devices.WOWZCameraView;
import com.wowza.gocoder.sdk.api.errors.WOWZError;
import com.wowza.gocoder.sdk.api.errors.WOWZStreamingError;
import com.wowza.gocoder.sdk.api.status.WOWZBroadcastStatus;
import com.wowza.gocoder.sdk.api.status.WOWZBroadcastStatus.BroadcastState;
import com.wowza.gocoder.sdk.api.status.WOWZBroadcastStatusCallback;
import com.wowza.gocoder.sdk.support.status.WOWZState;
import com.wowza.gocoder.sdk.support.status.WOWZStatusCallback;
import static com.wowza.gocoder.sdk.api.status.WOWZBroadcastStatus.BroadcastState.*;
// Main app activity class
public class MainActivity extends AppCompatActivity
implements WOWZBroadcastStatusCallback, View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize the GoCoder SDK
try {
goCoder = WowzaGoCoder.init(getApplicationContext(), "valid code is used ");
// Associate the WOWZCameraView defined in the U/I layout with the corresponding class member
goCoderCameraView = (WOWZCameraView) findViewById(R.id.camera_preview);
// Create an audio device instance for capturing and broadcasting audio
goCoderAudioDevice = new WOWZAudioDevice();
// Create a broadcaster instance
goCoderBroadcaster = new WOWZBroadcast();
// Create a configuration instance for the broadcaster
goCoderBroadcastConfig = new WOWZBroadcastConfig(WOWZMediaConfig.FRAME_SIZE_1920x1080);
// Set the connection properties for the target Wowza Streaming Engine server or Wowza Streaming Cloud live stream
goCoderBroadcastConfig.setHostAddress("valid");
goCoderBroadcastConfig.setPortNumber(1935);
goCoderBroadcastConfig.setApplicationName("valid");
goCoderBroadcastConfig.setStreamName("valid");
goCoderBroadcastConfig.setUsername("valid");
goCoderBroadcastConfig.setPassword("valid");
// Designate the camera preview as the video source
goCoderBroadcastConfig.setVideoBroadcaster(goCoderCameraView);
// Designate the audio device as the audio broadcaster
goCoderBroadcastConfig.setAudioBroadcaster(goCoderAudioDevice);
if (goCoder == null) {
// If initialization failed, retrieve the last error and display it
WOWZError goCoderInitError = WowzaGoCoder.getLastError();
Toast.makeText(this,
"GoCoder SDK error: " + goCoderInitError.getErrorDescription(),
Toast.LENGTH_LONG).show();
return;
}
// Associate the onClick() method as the callback for the broadcast button's click event
Button broadcastButton = (Button) findViewById(R.id.broadcast_button);
broadcastButton.setOnClickListener(this);
}catch (Exception e){
Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();
}
}
//
// Enable Android's immersive, sticky full-screen mode
//
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
if (rootView != null)
rootView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
// The top-level GoCoder API interface
private WowzaGoCoder goCoder;
// The GoCoder SDK camera view
private WOWZCameraView goCoderCameraView;
// The GoCoder SDK audio device
private WOWZAudioDevice goCoderAudioDevice;
// The GoCoder SDK broadcaster
private WOWZBroadcast goCoderBroadcaster;
// The broadcast configuration settings
private WOWZBroadcastConfig goCoderBroadcastConfig;
// Properties needed for Android 6+ permissions handling
private static final int PERMISSIONS_REQUEST_CODE = 0x1;
private boolean mPermissionsGranted = true;
private String[] mRequiredPermissions = new String[]{
Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO
};
@Override
protected void onResume() {
super.onResume();
// If running on Android 6 (Marshmallow) and later, check to see if the necessary permissions
// have been granted
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mPermissionsGranted = hasPermissions(this, mRequiredPermissions);
if (!mPermissionsGranted)
ActivityCompat.requestPermissions(this, mRequiredPermissions, PERMISSIONS_REQUEST_CODE);
} else
mPermissionsGranted = true;
// Start the camera preview display
if (mPermissionsGranted && goCoderCameraView != null) {
if (goCoderCameraView.isPreviewPaused())
goCoderCameraView.onResume();
else
goCoderCameraView.startPreview();
}
}
//
// Callback invoked in response to a call to ActivityCompat.requestPermissions() to interpret
// the results of the permissions request
//
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
mPermissionsGranted = true;
switch (requestCode) {
case PERMISSIONS_REQUEST_CODE: {
// Check the result of each permission granted
for(int grantResult : grantResults) {
if (grantResult != PackageManager.PERMISSION_GRANTED) {
mPermissionsGranted = false;
}
}
}
}
}
//
// Utility method to check the status of a permissions request for an array of permission identifiers
//
private static boolean hasPermissions(Context context, String[] permissions) {
for(String permission : permissions)
if (context.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
return false;
return true;
}
//
// The callback invoked upon changes to the state of the broadcast
//
@Override
public void onWZStatus(final WOWZBroadcastStatus goCoderStatus) {
// A successful status transition has been reported by the GoCoder SDK
final StringBuffer statusMessage = new StringBuffer("Broadcast status: ");
switch (goCoderStatus.getState()) {
case BroadcastState.READY:
statusMessage.append("Ready to begin broadcasting");
break;
case BroadcastState.BROADCASTING:
statusMessage.append("Broadcast is active");
break;
case BroadcastState.IDLE:
statusMessage.append("The broadcast is stopped");
break;
default:
return;
}
// Display the status message using the U/I thread
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, statusMessage, Toast.LENGTH_LONG).show();
}
});
}
//
// The callback invoked when an error occurs during a broadcast
//
@Override
public void onWZError(final WOWZBroadcastStatus goCoderStatus) {
// If an error is reported by the GoCoder SDK, display a message
// containing the error details using the U/I thread
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this,
"Streaming error: " + goCoderStatus.getLastError().getErrorDescription(),
Toast.LENGTH_LONG).show();
}
});
}
//
// The callback invoked when the broadcast button is tapped
//
@Override
public void onClick(View view) {
// return if the user hasn't granted the app the necessary permissions
if (!mPermissionsGranted) return;
// Ensure the minimum set of configuration settings have been specified necessary to
// initiate a broadcast streaming session
WOWZStreamingError configValidationError = goCoderBroadcastConfig.validateForBroadcast();
if (configValidationError != null) {
Toast.makeText(this, configValidationError.getErrorDescription(), Toast.LENGTH_LONG).show();
} else if (goCoderBroadcaster.getStatus().isBroadcasting()) {
// Stop the broadcast that is currently broadcasting
goCoderBroadcaster.endBroadcast((WOWZStatusCallback) this);
} else {
// Start streaming
goCoderBroadcaster.startBroadcast(goCoderBroadcastConfig, this);
}
}
}
Which version of the Android SDK are you using please?
What error are you seeing? And what version of the Android SDK are you using? Did you make sure to incorporate the SDK as it is not packaged with sample code?
Interface WOWZBroadcastStatusCallback not found please help i follow the official guideline in android
We stopped issuing licenses for the GoCoder SDK back on April, 2020. Wowza is discontinuing the SDK and if you did have a license to use it prior to April 1, 2020, you will need to submit a support ticket or send an email to smcr@wowza.com to receive support or learn what your other SDK options are.
https://www.wowza.com/community/articles/55594/attn-important-wowza-player-wowza-gocoder-sdk-ull.html
We stopped issuing licenses for the GoCoder SDK back on April, 2020. Wowza is discontinuing the SDK and if you did have a license to use it prior to April 1, 2020, you will need to submit a support ticket or send an email to smcr@wowza.com to receive support or learn what your other SDK options are.
https://www.wowza.com/community/articles/55594/attn-important-wowza-player-wowza-gocoder-sdk-ull.html