J2ME video capture throws MediaException: Invalid locator: capture://video - java-me

I was trying to capture a video in a J2ME application with the following snippet
private void createCamera() throws IOException, MediaException {
videoComponent = VideoComponent.createVideoPeer("capture://video");
videoComponent.setPreferredH(height);
videoComponent.setPreferredW(cameraForm.getWidth());
player = (Player) videoComponent.getNativePeer();
player.realize();
player.prefetch();
videoControl = (VideoControl) player.getControl("VideoControl");
}
When I run the application on a real device, I get the error:
javax.microedition.media.MediaException: Invalid locator: capture://video
If I use the string capture://image it will only show the camera for images only. How do I go about solving this problem?

Maybe you are to try get by device name, like devcam0/devcam1? Do you use nokia phone?

Related

How to get the current video frame while playing video by libvlcsharp?

How to get the current video frame while playing video by libvlcsharp?
I can play video with libvlcsharp by the codes below:
public void OnAppearing()
{
LibVLC = new LibVLC();
var media = new LibVLCSharp.Shared.Media(LibVLC, new Uri("http://live.cgtn.com/1000/prog_index.m3u8"));
MediaPlayer = new MediaPlayer(LibVLC)
{
Media = media
};
media.Dispose();
Play();
}
private void Play()
{
if (m_url != string.Empty)
{
MediaPlayer.Play(new LibVLCSharp.Shared.Media(LibVLC, new Uri(m_url)));
}
}
You could use the TakeSnapshot method. However please note:
The snapshot will be written to the disk, there's no way to get the frame in memory in VLC 3 (A new API for that will likely come in VLC4)
This is not meant to grab every frame, use it only for a snapshot.
If you need more frames, have a look at the Thumbnailer samples. They're not meant to grab all frames either.

How to play vimeo Video by using official library Vimeo Networking Library?

I want to play the Vimeo video in my android app by using Vimeo Official library : Vimeo networking library with the help of VideoView or ExoPlayer
The basic requirements for native playback are:
User must be logged in.
User must be the owner of the video.
User must be PRO or higher (or the app must have the "can access owner's video files" capability).
The token must have the video_files scope.
User must be the owner of the API app making the request.
Here is my complete code that helps me to play the video in android app by using Vimeo networking library
Presenting the final code
public class PlayActivity extends AppCompatActivity {
VideoView videoView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play);
videoView = findViewById(R.id.player);
// Getting access Token
String accessToken = getString(R.string.access_token);
Configuration.Builder configBuilder = new Configuration.Builder(accessToken)
.enableCertPinning(false);
//Vimeo Client autenticated
VimeoClient.initialize(configBuilder.build());
// the video uri; if you have a video, this is video.uri
you should use URI in this format
eg. I use the URI in 2nd format
https://api.vimeo.com/me/videos/123456789
final String uri = "https://api.vimeo.com/me/videos/123456789";
VimeoClient.getInstance().fetchNetworkContent(uri, new ModelCallback<Video>(Video.class) {
#Override
public void success(Video video) {
Toast.makeText(PlayActivity.this, "Sucessful" + video, Toast.LENGTH_SHORT).show();
ArrayList<VideoFile> videoFiles = video.files;
Log.i("TAG1", "videoFiles " + videoFiles);
if (videoFiles != null && !videoFiles.isEmpty()) {
VideoFile videoFile = videoFiles.get(0); // you could sort these files by size, fps, width/height
String link = videoFile.getLink();
Log.i("TAG2", "link " + link);
// load link
// use the link to play the video by **EXO Player** or **Video View**
// Start your video player here
}
}
#Override
public void failure(VimeoError error) {
Log.i("TAG3", "vimeo error : " + error.getErrorMessage());
Toast.makeText(PlayActivity.this, "failure due to " + error.getErrorMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}

Javafx how to setup a Media playlist

Ok I'm currently doing a Trivial Pursuit game project with javafx and my group wants me to add audio the problem is I have a method
public static void playSoundEffect(Sound sfx) {
Media media=null;
try {
media = new Media(GameAudio.class.getClassLoader().getResource(sfx.getSound()).toURI().toString());
mediaPlayer = new MediaPlayer(media);
mediaPlayer.play();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
But it has its issues because if I want to mute all the audio, only the last played sound will be muted and not the whole project's audio.
I was thinking of making 2 List of MediaPlayer(SFX and Music) that contains each audio files but I'm not sure how to set this up properly... My current try was using Enum for the const strings containing the path. Then in some class i use the method above to play the sound at a certain point. But since i always call a new instance of mediaPlayer I don't have any control on it anymore and that's why I'm so lost.
As #James_D supposed for the mute I will use a BooleanProperty muted and call a method mediaPlayer.muteProperty().bind(muted) on each mediaplayer created.

com.google.android.youtube.player.youtubeplayerview modestbranding is disabled or hide in android

google youtube player using
#Override
public void onInitializationSuccess(Provider arg0, YouTubePlayer player,
boolean restored) {
// TODO Auto-generated method stub
player.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
//This flag tells the player to automatically enter fullscreen when in landscape. Since we don't have
//landscape layout for this activity, this is a good way to allow the user rotate the video player.
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
if(!restored){ //lnIEn0kWdhY
player.cueVideo(getIntent().getStringExtra("VIDEO_ID"));
//player.cueVideo("lnIEn0kWdhY");
//player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
}
else {
Log.e("dd","dff");
}
}
Use the minimal video player style to hide the youtube icon. But it will show only timer bar play/pause controls.
player.setPlayerStyle(YouTubePlayer.PlayerStyle.MINIMAL);

How to get live camera preview in Windows Phone 8

I want to create an application in Windows phone8. In this application i want to show live camera preview with different effect in multiple frame using C# in Windows phone 8. please give me a solution
To use the camera in Windows phone 8 you need to use the PhotoCamera object. Best to create this object on your OnNavigatedTo like so:
protected override void OnNavigatedTo (System.Windows.Navigation.NavigationEventArgs e)
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true)
{
cam = new PhotoCamera(CameraType.Primary);
cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);
viewfinderBrush.SetSource(cam);
}
else
{
txtMessage.Text = "A Camera is not available on this device."; }
}
}
// dispose when we leave
protected override void OnNavigatingFrom (System.Windows.Navigation.NavigatingCancelEventArgs e)
{
if (cam != null)
{
cam.Dispose();
}
}
To actually capture the image from the camera you can then call the CaptureImage method on the cam object.

Resources