I'm trying to create a playlist viewer and I got stuck on paging.
I want to get all the names of current users playlists.
Any help would be appreciated.
public void getPlaylists() {
try {
SpotifyApi spotifyApi = new SpotifyApi.Builder().setAccessToken(auth.getToken()).build();
GetListOfCurrentUsersPlaylistsRequest getListOfCurrentUsersPlaylistsRequest = spotifyApi.getListOfCurrentUsersPlaylists().limit(5).offset(0).build();
Paging<PlaylistSimplified> playlistSimplifiedPaging = getListOfCurrentUsersPlaylistsRequest.execute();
} catch (IOException | SpotifyWebApiException e) {
System.out.println("Erroras: " + e.getMessage());
}
}
Okey so found out the answer myself don't know if its the correct way but it will work.
You can convert the paging object to a list :
List<PlaylistSimplified> playlists = Arrays.asList(playlistSimplifiedPaging.getItems());
And then get the info about your object normally.
Related
I am doing a webRTC videoCall application . At apoint I need a voice record ( Normal), So I just removed the audio track from peerconnection and after record I need to add audio track to peerconnection . But i cann't do it !!
public void removeAudioTrack() {
List<RtpSender> senders = new ArrayList<>();
senders.addAll(peerConnection.getSenders());
try {
for (RtpSender sender : senders) {
if (sender.track() != null) {
if (sender.track().id().equals(AUDIO_TRACK_ID)) {
boolean flag = peerConnection.removeTrack(sender);
rtpSender = sender;
}
}
}
} catch (Exception e) {
}
}
public void addAudioTrack() {
localAudioTrack = createAudioTrack();
mediaStream.addTrack(localAudioTrack);
audioSender = peerConnection.addTrack(localAudioTrack,mediaStreamLabels);
}
The audio voice not getting in another side (error)
As per the webrtc-pc standard - You cannot remove or add stream dynamically without re-negotiation. However, you can replace track to replace the current RTCPSender track with another track. And as per webrtc-pc standard this doesn't require a re-negotiation.
I am creating a playlist app where every playlist has a unique key and have 2 child elements playlistId and playlist name. I want to add songs as a child under the playlist name.
Like this:
But this is what I am getting instead:
My code which brings the above-unwanted error prone result is -
databaseReference = FirebaseDatabase.getInstance().getReference().child("a44f757c1f96ac85");
public void saveSongsToPlayList(View view){
try {
String song = "Song";
databaseReference.child(playListId).child(playListName)
.child("New song").child(song).setValue(song);
}catch (Exception ex){
ex.printStackTrace();
}
}
I don't think that I need to use the data snapshot for such a simple task. Or am I wrong?
Try this
public void saveSongsToPlayList(View view){
try {
Firebase firebase = new Firebase("https://your-firebase-id.com").child("a44f757c1f96ac85").child("LZIZ......").child("playListName").child("NewSong")
Firebase song1 = firebase.child("song")
song1.setValue("link to song or whatever")
}catch (Exception ex){
ex.printStackTrace();
}
}
I am developing an app that implements a SearchView used to get YouTube video results by keywords. The results are then refined by thumbnail url, video title, channel name, and video views, whose values are stored in an ArrayList. The ArrayList then sends values to a java class that then puts these results in a ListView to generate "results" for the user much like how the YouTube app returns videos. I am using the YouTube Data API V3 and am using slightly modified code from the Google example code. Here is my searchview listener code.
searchedList is the ArrayList that I would like to send the string values to.
searchYouTube = (SearchView)findViewById(R.id.videoSearch);
searchYouTube.setQueryHint("Search for a YouTube video");
searchYouTube.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{
#Override
public boolean onQueryTextSubmit(String s) {
String query = searchYouTube.getQuery().toString();
searchedList.clear();
try {
new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer() {
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("myApp").build();
// Define the API request for retrieving search results.
YouTube.Search.List search = youtube.search().list("id,snippet");
// Set your developer key from the Google Cloud Console for
// non-authenticated requests. See:
// https://cloud.google.com/console
search.setKey(apiKey);
search.setQ(query);
// Restrict the search results to only include videos. See:
// https://developers.google.com/youtube/v3/docs/search/list#type
search.setType("video");
// To increase efficiency, only retrieve the fields that the
// application uses.
search.setFields("items(id/kind,id/videoId,snippet/title,snippet/channelTitle,snippet/thumbnails/default/url)");
search.setMaxResults(NUMBER_OF_VIDEOS_RETURNED);
SearchListResponse searchResponse = search.execute();
List<SearchResult> searchResultList = searchResponse.getItems();
if (searchResultList != null) {
apppendToSearchArray(searchResultList.iterator(), query);
}
} catch (GoogleJsonResponseException e) {
System.err.println("There was a service error: " + e.getDetails().getCode() + " : "
+ e.getDetails().getMessage());
} catch (IOException e) {
System.err.println("There was an IO error: " + e.getCause() + " : " + e.getMessage());
} catch (Throwable t) {
t.printStackTrace();
}
return false;
}
#Override
public boolean onQueryTextChange(String s) {
return false;
}
});
Here is my method 'appendToSearchArray' method that is called in the above code to actually put the wanted values in order into the ArrayList.
private static void apppendToSearchArray(Iterator<SearchResult> iteratorSearchResults, String query) {
if (!iteratorSearchResults.hasNext()) {
System.out.println(" There aren't any results for your query.");
}
while (iteratorSearchResults.hasNext()) {
SearchResult singleVideo = iteratorSearchResults.next();
ResourceId rId = singleVideo.getId();
// Confirm that the result represents a video. Otherwise, the
// item will not contain a video ID.
if (rId.getKind().equals("youtube#video")) {
Thumbnail thumbnail = singleVideo.getSnippet().getThumbnails().getDefault();
VideoDetails singleVidDetails = new VideoDetails(thumbnail.getUrl().toString(),singleVideo.getSnippet().getTitle().toString(),singleVideo.getSnippet().getChannelTitle().toString(),"0");
searchedList.add(singleVidDetails);
}
}
}
"VideoDetails" is a java class I created that actually acts as a medium to retrieve String values of thumbnail, title, channel, and views and sends these Strings to an adapter class that actually implements them into my ListView. However, when the application is run and I submit a query via the SearchView the listview does not show any new results. Here is my logcat.
Logcat.png
ANY help is greatly appreciated because I am very confused.
I'm currently developing an android app that requires data to be inserted into an azure Mobile Service DB. An id string and a first login integer, to be exact. However the following error is being thrown up.
"IllegalArgumentException: The class representing the MobileServiceTable must have a single id property defined"
The id value that I need to insert into the database is being passed back from a fragment interface using passId(). Inside the override of this is where I am attempting to insert the values into azure as shown below.
#Override
public void passId(String id) {
userInstance user = new userInstance();
user.user_id = id;
user.first_login = 0;
mClient.getTable(userInstance.class).insert(user, new TableOperationCallback<userInstance>() {
public void onCompleted(userInstance entity, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
// Insert succeeded
} else {
// Insert failed
}
}
});
The mClient var represents the MobileServicesClient as shown below
try {
mClient = new MobileServiceClient(
"https://xxxx.azure-mobile.net/",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
this);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
The table name that I am trying to insert the data into is "user_table" if that helps at all.
I hope you're able to help, and thanks in advance for any help you guys give me.
SOLUTION:
Because the Azure Table that I was attempting to add data to auto created an "id" column, the user object that I was using to construct user info to insert into the database had to define an "id" String. As shown below:
public class userInstance {
#com.google.gson.annotations.SerializedName("id")
public String mId;
#com.google.gson.annotations.SerializedName("user_id")
public String mUserId;
#com.google.gson.annotations.SerializedName("first_login")
public int mLogin;
}
how to use google map with route in blackberry . i tried blackberry map with route but in my device (Storm 2) cant display map . i dont know what is the issue ?
any one have idea ragarding google map in blackberry application than let me know.
i tried this http://maps.google.com/maps?saddr=23.4444,72.44445&daddr=23.55555,72.55555
and open this url in BB browser but it cant redirect to map site .
how can we handle google map or blackberry map with route in BB application ?
i have implemented Google Map with route in Blackberry via Google Map Installed App.
public void invokeGoogleMap() {
int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
if (mh == 0)
{
try
{
throw new ApplicationManagerException("GoogleMaps isn't installed");
}
catch (ApplicationManagerException e)
{
System.out.println(e.getMessage());
}
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
stubDialog.inform("GoogleMaps isn't installed on your device.download it from m.google.com/maps.");
}
});
}
else
{
URLEncodedPostData uepd = new URLEncodedPostData(null, false);
uepd.append("action", "ROUT"); // or LOCN
uepd.append("start", "23.039568,72.566005");
uepd.append("end", "23.02,73.07");
String[] args = { "http://gmm/x?" + uepd.toString() };
ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0];
ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
try
{
ApplicationManager.getApplicationManager().runApplication(ad2, true);
}
catch (ApplicationManagerException e)
{
System.out.println(e.getMessage());
}
}
}
Blackberry browser is not fully functional for java script to display route info in browser field.Instead you have to use Blackberry maps. for this the following link will help you.
How to find the route between two places in BlackBerry?