I need to play a youtube video from my bb application. Does anyone know how to do that? Can I have a youtube video player directly inside my app or can I at least have a link to open youtube video in the browser?
What you want to do is get the rtsp streaming URL for the video. When I browse to YouTube on a BlackBerry with the native browser, it serves a page with links to this format. If you know exactly which video to play at build-time, great. If it's going to be picked by your users, you'll have to figure that out.
Then, with that URL, you can create a Player like this:
Player p = Manager.createPlayer("rtsp://SOME_YOUTUBE_VIDEO_ID_HERE/video.3gp");
p.realize();
VideoControl vc = (VideoControl)p.getControl("javax.microedition.media.control.VideoControl");
Field f = (Field)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );
The Field f can be added to your screen. And you can start the video with
p.start();
References:
http://docs.blackberry.com/en/developers/deliverables/11942/Create_BB_app_that_plays_streaming_media_739691_11.jsp
http://docs.blackberry.com/en/developers/deliverables/11942/Create_BB_app_that_plays_a_video_in_a_UI_field_739692_11.jsp
Related
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, videoLink);
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
I can send the link containing the video to someone on WhatsApp, however, I want to show the image of the video to the user on WhatsApp.
Is there a way to do this in java or kotlin
as in the picture
I am not sure what you're trying to do exactly but there are two options I can think of.
Firstly, if you're looking for something like what you have in the screenshot then no coding is required.
This is usually handled by Facebook when their bot scrapes the meta tags from the page that is shared.
If you wanted to accelerate this process you can manually put the link that you want to share in Facebook's Sharing Debugger and scrape it manually so that Facebook takes note of it.
Once that is done you can share the link and it should display video information including the image, title & description.
However, if you want to share only the video image/thumbnail you can do that as follows:
grab the video ID from the URL using REGEX or by taking a substring of the URL that holds the ID.
Plug that ID in one of the following URLs to get a link to an image that you can share instead of the video.
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/default.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
Thanks to #asaph for his details answer on getting Youtube thumbnail here
I've been working on a codenameone app recently, and one of the app features is to play the youtube video that i chose form a list.
The list is fullfilled with a "Movie" objects, and the movie contains an embed youtube URL, for an example "https://www.youtube.com/embed/r6VO3zaBJGY".
In my form, I created WebBrowser named "player" and that's what I did :
player = new WebBrowser();
String integrationCode= "<iframe src=\"" +videoUrl+"\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>";
player.setPage(integrationCode, null);
myForm.add(player);
it works, and I got the youtube player, but it looks aweful, and I can't put the player on full-screen.
Is there any alternative solution to play a video from a youtube URL ? or at least how can I put it on full-screen.
Thank you.
Notice that the way this looks on the simulator is different from the way it will appear on the device as youtube detects the device and adapts the rendering to it. The HTML rendering on the simulator is limited by what's available on JavaSE.
You can also customize the player appearance with a lot of optional arguments listed here: https://developers.google.com/youtube/player_parameters
I need to display the YouTube's video thumbnail image for every video searched or featured. I just need the syntax and method to implement it in my java swing application.
You can load the thumbnails directly via web request. Take a look at How do I get a YouTube video thumbnail from the YouTube API?
EDIT
Here are some sample links:
https://img.youtube.com/vi/<video-id>/default.jpg
https://img.youtube.com/vi/<video-id>/hqdefault.jpg
- or -
https://img.youtube.com/vi/<video-id>/maxresdefault.jpg
Assuming you get the SearchListResponse from youtube v3 data api. Now you can easily fetch the thumb url using following code.
SearchListResponse response = // data fetched from yt data api.
java.util.List<SearchResult> searchResultList = response.getItems();
for (SearchResult sr : searchResultList) {
String thumburl = sr.getSnippet().getThumbnails().getDefault().getUrl();
//for high resolution you can use: sr.getSnippet().getThumbnails().getHigh().getUrl();
}
related links. https://developers.google.com/youtube/v3/docs/search/list
i am creating a mediaplayer app which is supposed to stream mp3 files from remote url.the problem is that the everything works fine on the codename one simulator but not on an actual android device.I want the app to show native player controls like on the simulator.below is my code and screenshots
try {
video = MediaManager.createMedia(sample_url,true);
Display.getInstance().callSerially(() -> {
if (mp != null){
mp.getMedia().cleanup();
}
Image samp = theme.getImage("sample.png");
Label samlabel = new Label();
samlabel.setIcon(samp);
mp = new MediaPlayer(video);
mp.setAutoplay(false);
video.setNativePlayerMode(true);
sample.add(BorderLayout.CENTER,BorderLayout.centerAbsolute(samlabel));
sample.add(BorderLayout.SOUTH,mp);
//songDetails.add(mp);
});
the first image is the simulator screenshot and the second image is the actual android device screenshot
It's unclear from your post if this is an mp3 which is audio and doesn't have media control or an actual video. The MediaPlayer class is strictly for video and you passed true to indicate that this is a video file so I'll treat it as such.
Notice that if this is an audio file then you need to add/create your own controls and shouldn't use the MediaPlayer class.
We recently defined behaviors for native media control rendering as explained here.
Just use:
video.setVariable(Media.VARIABLE_NATIVE_CONTRLOLS_EMBEDDED, true);
I am developing an andorid app which post some photo on Facebook, at the same time I want to calculate the number of likes of that photo from my android app.
For information -
I am using Facebook SDK and I have successfully logged in Facebook account and posted the image.
The method which post image is below
private void PublishImage()
{
Bitmap image = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);
//Here we set all the required parameters to share the image and build that
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Testing Sharing Feature through java")
.build();
//Now we share the PhotoContent by adding the properties in instance of SharePhotoContent
share = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
//Now we use share API to share the image
ShareApi.share(share,null);
}
How to calculate the number of likes of posted photo with java instead of using Graph API Explorer manually ?
I don't think you can do that without the graph API. Once you call ShareApi.share (), there is actually a graph API request which uploads the photo, and you will get likes from various platforms, your app has no way of knowing how many likes have been posted