Is webcam detection still supported?
The MediaDiscovererTest.java file does not seem to detect any capture devices. (win/mac)
It seems to me that the device detection was working with earlier versions of vlcj on MAC webcam-capture driver for vlcj
...
MediaPlayerFactory mediaPlayerFactory = createMediaPlayerFactory();
MediaDiscoverer videoMediaDiscoverer = mediaPlayerFactory.newVideoMediaDiscoverer();
MediaList videoDeviceList = videoMediaDiscoverer.getMediaList();
List<MediaListItem> videoDevices = videoDeviceList.items();
...
VLC is able to detect the capture devices.
Thanks in advance for your help.
#edit1
Using the following code in vlcj-4.7.3 does not seem to return the webcam. But maybe I missed something.
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
List<MediaDiscovererDescription> videoDevices = mediaPlayerFactory.mediaDiscoverers().discoverers(MediaDiscovererCategory.DEVICES);
#edit 2
When i run this following code;
List<MediaDiscovererDescription> discoverers = factory.mediaDiscoverers().discoverers(MediaDiscovererCategory.DEVICES);
Under Windows 10 I get the following list: (no Video Capture)
[MediaDiscovererDescription[name=disc,longName=Discs,category=DEVICES],
MediaDiscovererDescription[name=disc,longName=Discs,category=DEVICES]
On MacOs 12.4 I get an empty list...
#edit 3
Capture device detection only works under linux
With vlcj-4.7.x, the API to discover video capture devices looks like this:
List<MediaDiscovererDescription> discoverers = factory.mediaDiscoverers().discoverers(MediaDiscovererCategory.DEVICES);
When I run that code, I see something like this:
[DEVICES ] v4l "Video capture"
[DEVICES ] disc "Discs"
[DEVICES ] xcb_apps "Screen capture"
[DEVICES ] mtp "MTP devices"
[DEVICES ] pulse "Audio capture"
In this case, on Linux, the discoverer ID is "v4l".
So now you find the "v4l" discoverer in the list of discoverer descriptions. Once you have that discoverer instance you can invoke methods on it to get the actual capture devices.
If you know the discoverer ID in advance, which in all (?) cases you will, you can do this instead:
MediaDiscoverer discoverer = factory.mediaDiscoverers().discoverer("v4l");
You then get the media list from that discoverer and add listeners to that media list.
Finally you must start() the discoverer.
The listener will be triggered when a capture device is added/removed (or 'detected').
MediaList list = discoverer.newMediaList();
list.events().addMediaListEventListener(new MediaListEventAdapter() {
#Override
public void mediaListItemAdded(MediaList mediaList, MediaRef item, int index) {
System.out.println(name + ": added " + item);
}
#Override
public void mediaListItemDeleted(MediaList mediaList, MediaRef item, int index) {
System.out.println(name + ": deleted " + item);
}
});
discoverer.start();
The vlcj MediaDiscovererTest class shows all of this.
The MediaRef instance is the MRL of the capture device, which you can then use to build a menu to select to play one of them or whatever.
Related
I am receiving notification payload as
[AnyHashable("jsonData"): {"packageName":"com.company.appName","appName":"AppName","orderId":"0","workflow":"PAGE_OWNER_STATUS_WORKFLOW"}, AnyHashable("aps"): {
alert = {
body = "You have received a new Order! ";
title = Orders;
};
sound = default;
},AnyHashable("google.c.a.e"): 1, AnyHashable("gcm.notification.jsonData"): {"packageName":"com.company.appName","appName":"AppName","orderId":"0","workflow":"PAGE_OWNER_STATUS_WORKFLOW"}, AnyHashable("title"): Orders, AnyHashable("google.c.sender.id"): 34781329473, AnyHashable("body"): You have received a new Order! , AnyHashable("sound"): phone_ringing.caf, AnyHashable("gcm.message_id"): 1597347128946557]
It does not add sound name in aps alert. Will it be done from backend?
We are using JAVA for Backend.
I believe the sound property has to be set as a property of the aps and not of the alert object, like you're receiving now and like it is specified in apple documentation. Apple example:
{
“aps” : {
“badge” : 9
“sound” : “bingbong.aiff”
},
“messageID” : “ABCDEFGHIJ”
}
You should specify the string "default" to play the default notification sound, otherwise a filename must be set and the file needs to exist on the app. These changes would have to be done on the server side.
I've got a game app and it requires repeated tapping. Some players are complaining that it doesn't work when they have the "triple tap to zoom" accessibility gesture enabled on their device.
Web search showed me that it can't be disabled within my game, but can it be detected? At least then I can explain to users how to turn it off while playing.
I'm not sure which android API I could use to check this setting. I'm not a native android developer, I work in Unity and Google isn't turning up anything.
Thanks to zcui93, I was able to test for this setting using the following Java:
Settings.Secure.getInt( context.getContentResolver(), "accessibility_display_magnification_enabled" );
...just check the return value: 1 = enabled, 0 = disabled
Here's the code to do it in a Unity C# Script:
public static bool CheckForSystemZoomEnabled()
{
#if UNITY_ANDROID
try {
using(AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver");
using(AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure"))
{
int val = clsSecure.CallStatic<int>("getInt", objResolver, "accessibility_display_magnification_enabled");
return val != 0;
}
}
} catch(System.Exception) { }
#endif
return false;
}
I am trying to get all the comments on a YouTube video using a Java program. I cannot get them though as it has the "Show More" instead of all the comments. I'm looking for a way to get all the comments or pages of comments that I can go through. I have a video id and things, just need the comments.
I have tried all_comments instead of watch in the URL but it doesn't show all comments still and redirects to watch again.
I have also looked at the YouTube api and can only find how to get comments with their id but I need to get all comments from a video id.
If anyone knows how to do this please tell me.
I have added a 50 rep bounty for whoever can give me a good answer to this.
You need to get comment threads list request for your video and then scroll forward using next page token from the last response:
private static int counter = 0;
private static YouTube youtube;
public static void main(String[] args) throws Exception {
// For Auth details consider:
// https://github.com/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/Auth.java
// Also don't forget secrets https://github.com/youtube/api-samples/blob/master/java/src/main/resources/client_secrets.json
List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube.force-ssl");
Credential credential = Auth.authorize(scopes, "commentthreads");
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential).build();
String videoId = "video_id";
// Get video comments threads
CommentThreadListResponse commentsPage = prepareListRequest(videoId).execute();
while (true) {
handleCommentsThreads(commentsPage.getItems());
String nextPageToken = commentsPage.getNextPageToken();
if (nextPageToken == null)
break;
// Get next page of video comments threads
commentsPage = prepareListRequest(videoId).setPageToken(nextPageToken).execute();
}
System.out.println("Total: " + counter);
}
private static YouTube.CommentThreads.List prepareListRequest(String videoId) throws Exception {
return youtube.commentThreads()
.list("snippet,replies")
.setVideoId(videoId)
.setMaxResults(100L)
.setModerationStatus("published")
.setTextFormat("plainText");
}
private static void handleCommentsThreads(List<CommentThread> commentThreads) {
for (CommentThread commentThread : commentThreads) {
List<Comment> comments = Lists.newArrayList();
comments.add(commentThread.getSnippet().getTopLevelComment());
CommentThreadReplies replies = commentThread.getReplies();
if (replies != null)
comments.addAll(replies.getComments());
System.out.println("Found " + comments.size() + " comments.");
// Do your comments logic here
counter += comments.size();
}
}
Consider api-samples, if you need a sample skeleton project.
Update
The situation when you can't get all the comments can be also caused by the quota limits (at least I faced it):
units/day 50,000,000
units/100seconds/user 300,000
This is not a java, python, js, or whatever language specific rules. If you want to get above the quota, you cant try to apply for higher quota. Though, I would start from controlling your throughput. It's very easy to get above the 100seconds/user quota.
try this it can download all the comments for a given video which i have tested.
https://github.com/egbertbouman/youtube-comment-downloader
python downloader.py --youtubeid YcZkCnPs45s --output OUT
Downloading Youtube comments for video: YcZkCnPs45s
Downloaded 1170 comment(s)
Done!
output is in the JSON format:
{
"text": "+Tony Northrup many thanks for the prompt reply - I'll try that.",
"time": "1 day ago",
"cid": "z13nfbog0ovqyntk322txzjamuensvpch.1455717946638546"
}
I am using the YouTube Data API V3 in Java and I am trying to "like" a video. I am using the following method:
private static String insertPlaylistItem(String playlistId, String videoId) throws IOException {
// Define a resourceId that identifies the video being added to the
// playlist.
ResourceId resourceId = new ResourceId();
resourceId.setKind("youtube#video");
resourceId.setVideoId(videoId);
// Set fields included in the playlistItem resource's "snippet" part.
PlaylistItemSnippet playlistItemSnippet = new PlaylistItemSnippet();
playlistItemSnippet.setTitle("First video in the test playlist");
playlistItemSnippet.setPlaylistId(playlistId);
playlistItemSnippet.setResourceId(resourceId);
// Create the playlistItem resource and set its snippet to the
// object created above.
PlaylistItem playlistItem = new PlaylistItem();
playlistItem.setSnippet(playlistItemSnippet);
// Call the API to add the playlist item to the specified playlist.
// In the API call, the first argument identifies the resource parts
// that the API response should contain, and the second argument is
// the playlist item being inserted.
YouTube.PlaylistItems.Insert playlistItemsInsertCommand =
youtube.playlistItems().insert("snippet,contentDetails", playlistItem);
PlaylistItem returnedPlaylistItem = playlistItemsInsertCommand.execute();
System.out.println("New PlaylistItem name: " + returnedPlaylistItem.getSnippet().getTitle());
System.out.println(" - Video id: " + returnedPlaylistItem.getSnippet().getResourceId().getVideoId());
System.out.println(" - Posted: " + returnedPlaylistItem.getSnippet().getPublishedAt());
System.out.println(" - Channel: " + returnedPlaylistItem.getSnippet().getChannelId());
return returnedPlaylistItem.getId();
}
The Method above came from the official YouTube Example located here:
https://developers.google.com/youtube/v3/docs/playlists/insert?hl=de#examples
I go the hint that I have to add the video to the "liked" playlist, which automatically adds a like to that video.
Here is how I get the Playlist for Likes
....
String likesPlaylistId = channelsList.get(0).getContentDetails().getRelatedPlaylists().getLikes();
insertPlaylistItem(likesPlaylistId, "pwi9TAKUMYI" );
If I like a video that I uploaded myself, it works. But If I try to like a video that another youtuber uploaded, the following error appears:
http://pokit.org/get/?d25a148b2a20d169488cf167d22ad7b0.jpg
I see the video as "liked" but the like counter isn't increasing. Noone else can see that like. Can anyone tell me what I am doing wrong? Is that a restriction? Or is it a prevention against Bots?
Have you tried actually getting the rating of a video? (https://developers.google.com/youtube/v3/docs/videos/getRating).
Get the rating of the video before and after liking the video and then you can verify if the rating count increased. There might be a graphical delay.
raw api call is :
GET https://www.googleapis.com/youtube/v3/videos/getRating?id=pwi9TAKUMYI&key={YOUR_API_KEY}
I'm working on the recurring serial number topic to provide a unique id.
I try this :
String serial = null;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
} catch (Exception ignored) {
}
and
StringBuilder sb = new StringBuilder();
sb.append("SERIAL ").append(android.os.Build.SERIAL).append("\n");
textReportAdmin.setText(
sb.toString());
Both gives the same value : C4F12FDD949F22F
On the box and on the sticker of my tab, the serial number is : RF2C202WYME
I work on a tab, no way to use
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imei = telephonyManager.getDeviceId();
IMEI is empty in my case.
SERIAL is what I need, but I need it in clear version as displayed on the sticker upon the barcode behind the tab.
I guess it is possible as, When going in the system app, and looking at the state of the device, it is displayed in clear...
How to convert the value returned by android.os.Build.SERIAL to the human visible one ?
EDITION : I also looked in :
sb.append("PRODUCT ").append(android.os.Build.PRODUCT).append("\n");
sb.append("BOARD ").append(android.os.Build.BOARD).append("\n");
sb.append("BOOTLOADER ").append(android.os.Build.BOOTLOADER).append("\n");
sb.append("BRAND ").append(android.os.Build.BRAND).append("\n");
sb.append("CPU_ABI ").append(android.os.Build.CPU_ABI).append("\n");
sb.append("CPU_ABI2 ").append(android.os.Build.CPU_ABI2).append("\n");
sb.append("DEVICE ").append(android.os.Build.DEVICE).append("\n");
sb.append("DISPLAY ").append(android.os.Build.DISPLAY).append("\n");
sb.append("FINGERPRINT ").append(android.os.Build.FINGERPRINT).append("\n");
sb.append("HARDWARE ").append(android.os.Build.HARDWARE).append("\n");
sb.append("HOST ").append(android.os.Build.HOST).append("\n");
sb.append("ID ").append(android.os.Build.ID).append("\n");
sb.append("MANUFACTURER ").append(android.os.Build.MANUFACTURER).append("\n");
sb.append("MODEL ").append(android.os.Build.MODEL).append("\n");
sb.append("PRODUCT ").append(android.os.Build.PRODUCT).append("\n");
sb.append("RADIO ").append(android.os.Build.RADIO).append("\n");
sb.append("SERIAL ").append(android.os.Build.SERIAL).append("\n");
sb.append("TAGS ").append(android.os.Build.TAGS).append("\n");
sb.append("TIME ").append(android.os.Build.TIME).append("\n");
sb.append("TYPE ").append(android.os.Build.TYPE).append("\n");
sb.append("USER ").append(android.os.Build.USER).append("\n");
nowhere, I get the serialnumber as on the sticker, while it can be possible to be found as ,the system itself is able to display it in "Parameters", "About", "State" (I don't know the words in english, I have a french tab, and it is "Paramètres", "A propos de", "Etat" and then "Serial Number", the clear version, as on the sticker.
Have you tried this?
String serial = null;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ril.serialnumber");
} catch (Exception ignored) {
}
If you want to get the serial number as shown on the back of the device and if you are using the Samsung Galaxy Tab then why not use the 'ril.serialnumber' property
Items changed to what your device should show:
$ adb shell getprop | grep serial
[ril.serialnumber]: [RF2C202WYME]
[ro.boot.serialno]: [c4f12fdd949f22f]
[ro.serialno]: [c4f12fdd949f22f]
Pre-jellybean 'ro.boot.serialno' didn't exist
On many devices there is information displayed in the Settings --> About activity that is non-standard and is not available from any standard Android API. For example, the FCC ID is sometimes displayed there but is not available to apps.
Also, there is no requirement that the serial number available through the API's be the product's 'real' serial number (i.e. the one on the package). Just that it be unique.
So, I think there is no way to do what you want (read the serial number that is on the box and in the about activity) other then look through that product's source code (if available) and see if there is a way to get that info for that particular product or manufacturer.
you should use
sys.serialnumber ,some devices have ril.serialnumber and some have sys.serialnumber ,so you should try sys one