Working with connectSDK Android for casting videos on samsung android Tv.
I've successfully launch the default youtube app and played as well.
But when ever i'm trying to stop the currently running Youtube video getting a response code = 400 i.e
com.connectsdk.service.command.ServiceCommandError: Bad Request
Anyone worked on this? or familiar with the issue?
Code:
if (runningAppSession != null) {
if (runningAppSession.getSessionType() == LaunchSessionType.App) {
getLauncher().closeApp(runningAppSession, new ResponseListener<Object>() {
#Override
public void onError(ServiceCommandError error) {
System.out.println(error);
}
#Override
public void onSuccess(Object object) {
System.out.println(object.toString());
}
});
}
}
Related
I'm using the facebook-sdk for the facebook login button. This the facebook library I'm using:
implementation ('com.facebook.android:facebook-android-sdk:4.0.0'){
exclude group: 'com.android.support'
}
This is the crash raised by Firebase Crashlytics:
https://i.stack.imgur.com/jqArL.png
On this devices:
Galaxy S7 not rooted Android 7.0
Huawei Honor 9(STF-L09) not rooted Android 8.0
I check the code to know what is the Facebook library doing but I didn't find anything that I can do from my code to solve it. This is the method that raised the crash(LoginFragment.java line 68):
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
loginClient = savedInstanceState.getParcelable(SAVED_LOGIN_CLIENT);
loginClient.setFragment(this);
} else {
loginClient = new LoginClient(this);
}
callingPackage = getActivity().getCallingActivity().getPackageName();
request = (LoginClient.Request)
getActivity().getIntent().getParcelableExtra(EXTRA_REQUEST);
loginClient.setOnCompletedListener(new LoginClient.OnCompletedListener() {
#Override
public void onCompleted(LoginClient.Result outcome) {
onLoginClientCompleted(outcome);
}
});
}
This is the getCallingActivity method that returns null from android.app.Activity.java
public ComponentName getCallingActivity() {
try {
return ActivityManager.getService().getCallingActivity(mToken);
} catch (RemoteException e) {
return null;
}
}
I cannot reproduce the error with the testing devices at the office so I only have the Crashlytics report to solve it. I 'm clueless because it seems to work for most of the devices
Any help would be amazing, thanks in advance
I am developing a game in LibGdx for android device. I could see a strange issue in using Gdx.input.justTouched(). It is working in some device and not in some device. Could you please help me if my code needs any correction?
#Override
public void create() {
Gdx.input.setInputProcessor(this);
Gdx.input.setCatchBackKey(true);
}
public void render(SpriteBatch sb) {
if (Gdx.input.justTouched()){
System.out.println("inside : " );
dragNew = new Vector2(Gdx.input.getX(), Gdx.input.getY());
dragOld = dragNew;
}
}
I've got a Andriod Studio project and I'm trying to use the SocketIOClient from the AndroidAsync library. I'm building the library with the command:
dependencies {
compile 'com.koushikdutta.androidasync:AndroidAsync:1.0.0'
}
I was able to get the websocket example to work, but there's seems to be a version issue with the 1.0 and the SocketIOClient example. I've also tried using the 2.0 jar file, but SocketIOClient doesn't appear to be defined there at all(this is one of my first andriod applications, so maybe I'm just doing something wrong). Does anyone know what needs to be done to get the following code to compile:
SocketIOClient.connect(AsyncHttpClient.getDefaultInstance(), "http://192.168.1.2:3000", new ConnectCallback() {
#Override
public void onConnectCompleted(Exception ex, SocketIOClient client) {
if (ex != null) {
ex.printStackTrace();
return;
}
client.setStringCallback(new StringCallback() {
#Override
public void onString(String string) {
System.out.println(string);
}
});
client.on("someEvent", new EventCallback() {
#Override
public void onEvent(JSONArray argument, Acknowledge acknowledge) {
System.out.println("args: " + arguments.toString());
}
});
client.setJSONCallback(new JSONCallback() {
#Override
public void onJSON(JSONObject json) {
System.out.println("json: " + json.toString());
}
});
}
});
Thanks,
Scott
I am attempting to write a RemotePlaybackClient sample app, in part because the one published by Google crashes aapt.
I can get RemotePlaybackClient to support play(), and it plays back a video on a Chromecast.
However, when I call stop(), to stop playback of the video, while the Chromecast does stop playback (showing a black screen with a cast icon centered), the SessionActionCallback that I pass into the stop() call does not get called with onResult():
private void stop() {
logToTranscript(getActivity().getString(R.string.stop_requested));
SessionActionCallback stopCB=new SessionActionCallback() {
#Override
public void onResult(Bundle data, String sessionId,
MediaSessionStatus sessionStatus) {
logToTranscript(getActivity().getString(R.string.stopped));
isPlaying=false;
isPaused=false;
getActivity().supportInvalidateOptionsMenu();
endSession();
}
};
client.stop(null, stopCB);
}
The same thing happens if I try pause() -- the SessionActionCallback passed to pause() is not invoked.
The sample code published by Google shows that these callbacks should be invoked, but, again, I can't get that to compile successfully.
Does anyone know under what circumstances the SessionActionCallback would not work, while the ItemActionCallback used with play() would work?
UPDATE
I have filed issue 66996 and issue 67032, the latter of which is specifically the problem I am seeing here, as I run into this same problem with the official sample app.
I beleive all Answer reside on how you make connection.
Because in google code ,code says that client which you had made shold not leave session and should not be null.
if (!mClient.hasSession()) {
// ignore if no session
return;
}
/*********Rest of the code would be unreachable***********/
#Override
public void pause() {
if (!mClient.hasSession()) {
// ignore if no session
return;
}
if (DEBUG) {
Log.d(TAG, "pause");
}
mClient.pause(null, new SessionActionCallback() {
#Override
public void onResult(Bundle data, String sessionId, MediaSessionStatus sessionStatus) {
logStatus("pause: succeeded", sessionId, sessionStatus, null, null);
if (mCallback != null) {
mCallback.onPlaylistChanged();
}
}
#Override
public void onError(String error, int code, Bundle data) {
logError("pause: failed", error, code);
}
});
}
I'm testing playing online video using chromecast.
After onRouteSelected(), I create the ApplicationSession and attach a MediaProtocalMessageStream;
Then I called mSession.startSession(); with no APP_ID, so I assume the build-in app inside chromecast play the video for me. This code works perfect and I can play online mp4 videos without writing my own receiver.
But, When I try to leave the video play app, I can't go back anymore, there is always an error message comes from onSessionStartFailed() which says
StartSessionTask failed with error: failed to start application: no
application is running
I don't remember how the first time I got into the video play app, which I don't leave for few day.
But I do know how I leave it, Here is what I did before I can never startSession again:
open Youtube app, get a deviced connected
play some youtube videos
disconnected from a chormecast, then the chromecast return to the starting page
So, doesn't anybody know what's going on here? How to open the build-in video app again?
By the way, My chromecast get a system update just after I return to the starting page, I don't know if google update something cause startSession() fail.
Below is the code I startSession and attach a mediaStream.
mSession = new ApplicationSession(mCastContext, mSelectedDevice);
ApplicationSession.Listener listener = new ApplicationSession.Listener() {
#Override
public void onSessionStarted(ApplicationMetadata appMetadata) {
mChannel = mSession.getChannel();
mStream = new MediaProtocolMessageStream();
mChannel.attachMessageStream(mStream);
if (mStream.getPlayerState() == null) {
ContentMetadata metaData = new ContentMetadata();
metaData.setTitle("Test Video");
String url = "http://www.auby.no/files/video_tests/h264_720p_hp_5.1_6mbps_ac3_planet.mp4";
try {
mCommand = mStream.loadMedia(url, metaData, true);
mCommand.setListener(new MediaProtocolCommand.Listener() {
#Override
public void onCompleted(MediaProtocolCommand arg0) {
onSetVolume(0.5);
}
#Override
public void onCancelled(MediaProtocolCommand arg0) {
}
});
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
#Override
public void onSessionStartFailed(SessionError error) {
Log.d("TEST", "Session Started failed");
}
#Override
public void onSessionEnded(SessionError error) {
Log.d("TEST", "Session Started end");
}
};
mSession.setListener(listener);
try {
mSession.startSession();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
You will have to use your own app id and own receiver. Google's default receiver doesn't play video streams anymore (it used to). It only handles Chrome tab mirroring now.