Vitamio, VideoView and RTMPGW issues - android-videoview

I am trying to utilise RTMPGW as part of my app, which usually works great in Linux. I am trying to use the Vitamio bundle to play back the stream. Here is the main code, taken from the Vitamio Demo:
package io.vov.vitamio.demo;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
public class VideoViewDemo extends Activity {
private VideoView mVideoView;
/* (non-Javadoc)
* #see android.app.Activity#onCreate(android.os.Bundle)
*/
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoURI(Uri.parse("http://172.16.1.182:8902/?r=rtmp://live.dtv.cubecdn.net:80/kdmobil/KanalD1&W=http://www.kanald.com.tr/Content/swf/Canliplayer6.swf?config=/Content/swf/Config.xml%26debug=false&p=http://www.kanald.com.tr&c=80"));
mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
#Override
public void onConfigurationChanged(Configuration newConfig) {
if (mVideoView != null)
mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
super.onConfigurationChanged(newConfig);
}
}
When I run this, RTMPGW (which I am running from the terminal in Linux) displays this error:
processTCPrequest, Range request not supported
..and sits there idly, doing nothing.
However, when I use regular Android VideoView with this code (in a different project):
package com.sample.videoviewexample;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class MainActivity extends Activity {
private VideoView mVideoView;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoURI(Uri.parse("http://172.16.1.182:8902/?r=rtmp://live.dtv.cubecdn.net:80/kdmobil/KanalD1&W=http://www.kanald.com.tr/Content/swf/Canliplayer6.swf?config=/Content/swf/Config.xml%26debug=false&p=http://www.kanald.com.tr&c=80"));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
It connects to the RTMPGW server and starts streaming like so...
Streaming on http://0.0.0.0:8902
processTCPrequest, Range request not supported
Connecting ... port: 80, app: kdmobil/KanalD1
1094.914 KB / 16.90 sec
But, of course, as Android MediaPlayer doesn't support Flash natively it won't play back the video.
Why does the VideoView connect with RTMPGW's server but Vitamio doesn't?
Thanks for your help,
Dan

Related

Downloading rest objects instead of showing in eclipse browser

Everytime i try to show the results from the page, it downloads the results in json format instead of showing them on page.
It starts to download when i enter the url where the objects/information is stored, instead of showing the page http://localhost:8082/spring-rest-demo/api/students
If i run the server and paste this info in postman og google chrome, it does show the correct information without downloading it as a json file.
this is how it should be
Thank you
Edit:
package com.luv2code.springdemo.rest;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.luv2code.springdemo.entity.Student;
#RestController
#RequestMapping("/api")
public class StudentRestController {
private List<Student> theStudents;
// define #PostConstruct to load the student data only once!
#PostConstruct
public void loadData() {
theStudents = new ArrayList<>();
theStudents.add(new Student("Poornima", "Patel"));
theStudents.add(new Student("Mario", "Rossi"));
theStudents.add(new Student("Mary", "Smith"));
}
// define endpoint for "/Student"-- return list of students
#GetMapping("/students")
public List<Student> getStudents() {
return theStudents;
}
// define endpoint for "/Student({studentid}"-- return list of students at index
#GetMapping("/students/{studentId}")
public Student getStudent(#PathVariable int studentId) {
// just index into the list .... keep it simple for now
return theStudents.get(studentId);
}
}
Try to add produces application/json in #GetMapping annotation.
This is a bug in recent versions of Eclipse. Hopefully the Eclipse team will fix it soon

Android crashes while sending json object

I am trying to send json object through volley in android studio to a server (mvc spring project in eclipse + tomcat is listening) but the app crashes. I'm new to the volley library. Also, the json object is made up of the data gotten from user inputs in combo box and textviews.
Login Activity:
package com.example.mujtaba.quizzer;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import com.android.volley.Cache;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.StringRequest;
import com.example.mujtaba.quizzer.Activity.QuizMaking;
import com.example.mujtaba.quizzer.Activity.QuizTaking;
import org.w3c.dom.Text;
import java.util.HashMap;
import java.util.Map;
public class Login extends AppCompatActivity {
private Button button;
private TextView username;
private TextView password;
private Spinner role;
private String url = "http://localhost:8080/users/signup";
private RequestQueue queue;
private ProgressDialog progress;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
username=(TextView) findViewById(R.id.username);
password=(TextView) findViewById(R.id.password);
button=(Button) findViewById(R.id.button);
role = (Spinner) findViewById(R.id.role);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.role_spinner, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
role.setAdapter(adapter);
}
public void Quiz(View v) { //select a new activity on the basis of role
// Instantiate the cache
Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap
// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());
// Instantiate the RequestQueue with the cache and network.
queue = new RequestQueue(cache, network);
// Start the queue
queue.start();
StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
//This code is executed if the server responds, whether or not the response contains data.
//The String 'response' contains the server's response.
}
}, new Response.ErrorListener() { //Create an error listener to handle errors appropriately.
#Override
public void onErrorResponse(VolleyError error) {
//This code is executed if there is an error.
}
}) {
protected Map<String, String> getParams() {
Map<String, String> MyData = new HashMap<String,String>();
MyData.put("Username", username.getText().toString() ); //Add the data you'd like to send to the server.
MyData.put("Password",password.getText().toString());
MyData.put("Role",role.getSelectedItem().toString());
MyData.put("Score","0");
return MyData;
}
};
queue.add(MyStringRequest);
}
}
Logcat error:
*3430-3440/com.android.dialer E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:184)
at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:57)
at android.os.Binder.execTransact(Binder.java:446)*

How can I use DJNativeSwing JWebBrowser as the browser for the jupyter notebook?

I am using chrriis.dj.nativeswing.swtimpl.components.JWebBrowser in my swing application to open web page of a jupyter-notebook. Now my problem is when I click New->Python 3 button JWebBrowser to new a file, it always return the 404 page.
New a notebook in DJNativeSwing JWebBrowser
DJNativeSwing JWebBrowser got the 404 page
I think maybe it did not execute the javascript api in jupyter-notebook, can anyone help me make the DJNativeSwing JWebBrowser work under jupyter notebook?
The code I used:
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowserWindow;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserAdapter;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserNavigationEvent;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserWindowFactory;
import chrriis.dj.nativeswing.swtimpl.components.WebBrowserWindowWillOpenEvent;
/**
* #author Christopher Deckers
*/
public class NavigationControl extends JPanel {
protected static final String LS = System.getProperty("line.separator");
public NavigationControl() {
super(new BorderLayout());
final JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
final JWebBrowser webBrowser = new JWebBrowser();
webBrowser.setBarsVisible(false);
webBrowser.setStatusBarVisible(true);
webBrowser.navigate("https://try.jupyter.org/");
tabbedPane.addTab("Controled Browser", webBrowser);
add(tabbedPane, BorderLayout.CENTER);
}
/* Standard main method to try that test as a standalone application. */
public static void main(String[] args) {
UIUtils.setPreferredLookAndFeel();
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("DJ Native Swing Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new NavigationControl(), BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
NativeInterface.runEventPump();
}
}
Thanks Thomas K. I changed the engine of jwebbrowser to Xulrunner-24.0.en-US and the problem disappeared.

Creating simple REST webservice on Eclipse

I am trying to start with a simple web service following the example : https://spring.io/guides/gs/rest-service/
I am unable to get any response when I hit the service URL. The way I am trying to run this is by running the project on Apache web server from Eclipse.
This is my controller:
package com.nscm.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nscm.model.User;
#RestController
public class NSCMController {
#RequestMapping("/getuser")
public User getUser()
{
System.out.println("NSCMController.getUser()");
return new User();
}
}
This is my service class:
package com.nscm.service;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;
#ComponentScan("com")
#EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
System.out.println("Application.main()");
SpringApplication.run(Application.class, args);
}
}
Even though as the example mentions the web.xml and the spring.xml is not required, even after placing these, my code does not work. None of the SOPs are called when I hit the URL. Please help me if I am missing anything here.

Javafx webview 'outstanding resource locks detected' message

I am using javafx webview to load a local html page in a jpanel. Executing the code gives me following message:
Outstanding resource locks detected: D3D Vram Pool: 13,810,710 used (5.1%), 13,810,710 managed (5.1%), 268,435,456 total
14 total resources being managed
average resource age is 0.8 frames
0 resources at maximum supported age (0.000000)
3 resources marked permanent (21.400000)
3 resources have had mismatched locks (21.400000)
3 resources locked (21.400000)
5 resources contain interesting data (35.700000)
I am new to java and I don't understand why this message is being generated and how it could be resolved (my html page works fine and so does the swing code - gives me the desired result).I tried looking it up online but was unable to find a solution.
Please let me know if any other information is needed.
Edit:
I'm trying to develop a video annotation tool. The tags to be attached to the video and their handling is all done in java swing. The video itself is a part of the html page I'm loading in a javafx webview. I've placed a semi-transparent canvas on it which I'm using to register mouse-click events to attach the tags to specific content on the video at a certain time. Below the video tag is another canvas which acts as the timeline (shows attached tags at the appropriate time). That's the basic goal for the code.
Here's the code where I add my jfxpanel:
package codingAnnotations;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javax.swing.JPanel;
#SuppressWarnings("serial")
public class JFXContainerPanel extends JPanel {
private final JFXPanel WebViewContainer;
private final JFXPanel TimeLineContainer;
public JFXContainerPanel(){
WebViewContainer = new JFXPanel();
TimeLineContainer = new JFXPanel();
add(WebViewContainer);
Platform.runLater(new Runnable() {
#Override
public void run() {
initFX(WebViewContainer);
}
});
}
private static void initFX(final JFXPanel fxPanel) {
Group group = new Group();
Scene scene = new Scene(group);
WebView webView = new WebView();
group.getChildren().add(webView);
webView.setMinSize(500, 500);
webView.setMaxSize(800, 600);
final String html = "res/VideoCanvas.html";
final java.net.URI uri = java.nio.file.Paths.get(html).toAbsolutePath().toUri();
System.out.println(uri.toString());
WebEngine webEngine = webView.getEngine();
webEngine.load(uri.toString());
webEngine.setOnAlert(new EventHandler<WebEvent<String>>(){
#Override
public void handle(WebEvent<String> arg0) {
String value = arg0.toString().substring(10, arg0.toString().length() - 1);
System.out.println(value);
}
});
fxPanel.setScene(scene);
}
}
Thanks for your help!