Jump to content

pcplayer99

Members
  • Content Count

    69
  • Joined

  • Last visited

Everything posted by pcplayer99

  1. pcplayer99

    Android, how to call a TJIntent

    On Android 6, I can play MP4 by call TJIntent: uri := StrToJURI('file://' + AURI); Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW); intent.setDataAndType(uri, StringToJstring('video/mp4')); TAndroidHelper.Activity.startActivity(Intent); On Android 9, there is a exception: raised exception class EJNIException with message 'android.os.FileUriExposedException: file:///storage/emulated/0/Download/VIDOES/4114049.mp4 exposed beyond app through Intent.getData() I have googled on Internet, it must use file provider. There is a demo code in: https://community.idera.com/developer-tools/platforms/f/android-platform/68376/my-apps-autoupdate-not-working-rio-10-3-1-tokyo-10-2-3-working and in this link: https://www.delphiworlds.com/2018/06/targeting-android-8-and-higher-continued/ it is said that we need add some provider code into AndroidManifest.template. So, I write code like this: AJavaFile := TJFile.JavaClass.init(StringToJstring( AURI)); uri := TAndroidHelper.JFileToJURI(AJavaFile); and update AndroidManifest.template file add some code in it: <application android:persistent="%persistent%" android:restoreAnyVersion="%restoreAnyVersion%" android:label="%label%" android:debuggable="%debuggable%" android:largeHeap="%largeHeap%" android:icon="%icon%" android:theme="%theme%" android:hardwareAccelerated="%hardwareAccelerated%" android:resizeableActivity="false"> <%provider%> <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.embarcadero.firemonkey.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </provider> <%application-meta-data%> <%services%> <!-- Our activity is a subclass of the built-in NativeActivity framework class. This will take care of integrating with our NDK code. --> <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" android:label="%activityLabel%" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" android:launchMode="singleTask"> <!-- Tell NativeActivity the name of our .so --> <meta-data android:name="android.app.lib_name" android:value="%libNameValue%" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <%activity%> <%receivers%> </application> another XML file is provider_paths.xml, like this: <?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="."/> </paths> but when call "uri := TAndroidHelper.JFileToJURI(AJavaFile); " there is a exception: raised exception class EJNIException with message 'java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference'. So, is there a demo that how to call a TJIntent on Android 7 or higher version?
  2. In unit Soap.SOAPLinked.pas there are: 1. TLinkedWebNode 2. TLogLinkedWebNode = class(TLinkedWebNode) 3. TLinkedRIO = class(TRIO) in TLinkedRIO, it has two constructor: one is for: FLinkedWebNode := TLinkedWebNode.Create(nil); and another is for: FLinkedWebNode := TLogLinkedWebNode.Create(nil); My question is: if I want to create a new TLinkedWebNode like TLogLinkedWebNode, Just named it TMyWebNode, I must let TLinkedRIO has a new constructor that lets it create FLinkedWebNode as my new TMyWebNode. but, I can not modify Soap.SOAPLinked.pas because it is source code in Delphi. I will create a new pas file and inherit TLinkedRIO like TMyRIO = class(TLinkedRIO) and add a new constructor in it. but, the new TMyRIO in a new pas unit, I can not access FLinkedWebNode like FLinkedWebNode := TMyWebNode.Create(nil); So, is there any way to do that? or this is a design issue in Soap.SOAPLinked.pas and I must modify it?
  3. with MyDataSet do begin FieldByName('aaa').AsString := 'abcd'; FieldByName('bbb').AsInteger := 234; etc... end; This ca reduce typing.
  4. Thanks FredS, after I add "With Self do" in my helper class, it can access provate field in another unit. in unit1, here is TMyClassB: TMyClassB = class private FMyClassA: TMyClassA; function GetMyName: string; public constructor Create; property MyName: string read GetMyName; end; in Unit2, here is my helper class: TMyClassB3 = class helper for TMyClassB public constructor Create(B: Boolean); overload; end; constructor TMyClassB3.Create(B: Boolean); begin //if B then FMyClassA := TMyClassA2.Create; //helper class can not access private field. //use with self do, here can access private field with Self do begin FMyClassA := TMyClassA2.Create; end; end;
  5. My test code as: constructor TMyClassB3.Create(B: Boolean); begin if B then FMyClassA := TMyClassA2.Create; end; The field "FMyClassA" is declared in TMyClassB2 in another unit, and this code can not compile. because field "FMyClassA" is a private field of TMyClassB2.
  6. I have done a test if the class helper is in a different unit with the original class, it can not access private field in original class.
  7. Thank you Fred. I will try helper class mode.
  8. Yes, this is why I do not want to copy it and modify it, I just want to inherit a new class in a new unit, to avoid modify Delphi's source file.
  9. pcplayer99

    Drone control from mobile

    I have made a drone controller APP years ago. It was made by Firemonkey, through WiFi to communication with a WiFi camera, play real time video stream from camera on the drone, and send control command to camera and the camera forward this command to drone controller through UART.
  10. pcplayer99

    Soap Server and client downloading files

    Hi, here is my demo project: https://github.com/pcplayer/WebServiceUploadFile
  11. pcplayer99

    best component for web media player

    [Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.] According to the above statement, it just supports draw the image to the screen, there is no decoder in it. To using DirectShow, there is H.264 decoder you can use. There is an open-source decoder for DirectShow named FFDShow.
  12. pcplayer99

    best component for web media player

    [SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.] So, I do not know if it is can be used in Delphi. I have updated Dspack to let it can compile in higher version Delphi, so, it is still can be used in the new version of Delphi. Here is my updated version: https://github.com/pcplayer/Dspack In Windows, DirectShow still exists, and if you using Delphi to play media, you still can using DirectShow. And Dspack is a set of open-source Delphi code for DirectShow.
  13. pcplayer99

    best component for web media player

    if you use VCL then your app will run under windows. So I suggest you should use Directshow to build your media-player. There is an open-source component named DSPACK for DirectShow.
  14. pcplayer99

    Soap Server and client downloading files

    Hi, These codes I have tested ok. Server Side: unit TestAttachImpl; interface uses Soap.InvokeRegistry, System.Types, System.SysUtils, Soap.XSBuiltIns, TestAttachIntf; type { TTestAttach } TTestAttach = class(TInvokableClass, ITestAttach) public procedure GetAttach(var FileName: string; out Attach: TSOAPAttachment); stdcall; procedure PutAttach(const FileName: string; Attach: TSOAPAttachment); stdcall; end; implementation { TTestAttach } procedure TTestAttach.GetAttach(var FileName: string; out Attach: TSOAPAttachment); var Fn: string; begin //Send file to client Fn := 'F:\H264Output.mp4'; Attach := TSOAPAttachment.Create; Attach.SetSourceFile(Fn); FileName := ExtractFileName(Fn); end; procedure TTestAttach.PutAttach(const FileName: string; Attach: TSOAPAttachment); begin //receive file that client upload Attach.SaveToFile(ExtractFilePath(GetModuleName(0)) + FileName); end; initialization { Invokable classes must be registered } InvRegistry.RegisterInvokableClass(TTestAttach); end. Client-side: procedure TForm2.Button1Click(Sender: TObject); var Attach: TSOAPAttachment; Intf: ITestAttach; Path, Fn: string; begin //client download file Path := ExtractFilePath(Application.ExeName); Attach := TSOAPAttachment.Create; Intf := HTTPRIO1 as ITestAttach; try Intf.GetAttach(Fn, Attach); Attach.SaveToFile(Path + Fn); finally Intf := nil; Attach.Free; end; end; procedure TForm2.Button2Click(Sender: TObject); var Fn: string; Attach: TSOAPAttachment; Intf: ITestAttach; begin //client upload file if OpenDialog1.Execute then begin Fn := OpenDialog1.FileName; Attach := TSOAPAttachment.Create; Attach.SetSourceFile(Fn); Intf := HTTPRIO1 as ITestAttach; try Intf.PutAttach(ExtractFileName(Fn), Attach); finally Intf := nil; Attach.Free; end; end; end;
  15. Hi, OK, you can not setup router. Then you must have a server on the Internet that your LAN APP and your Android APP can get connected. This is not about callbacks or other tech. This is about how tow to establish communication between two device. Under normal conditions, to establish connection between two device, there must be a server, both device connect to this server, this server is working as a bridge.
  16. pcplayer99

    QUIC and HTTP/3

    Hi, Google will support HTTP/3 on QUIC in Chrome brwoser. Is there any Delphi library that support QUIC? Thanks.
  17. Your issue is: A server working in a LAN server which has a private IP address, and your client want to access from Internet. If your LAN has a Internet router, and if you can setup the port mapping of this router, then your client can access your server from Internet. This is a simple diagram of port mapping: Internet -- xx.xx.xx.xx(Your router's public IP address) --- (port 8888: 192.168.1.20:9999 -- this is the port mapping setup in your router) --- Your Server on 192.168.1.20:9999. If your router's public IP address is dynamic, you will using some dynamic DNS services to let a fixed DNS name point to your dynamic IP address.
  18. SOAP is for WebService,it is stable since Delphi 7. WebService framework is buit-in delphi since Delphi 7.
  19. pcplayer99

    What is the best way LoadFromFile & Thread? (FMX)

    You said that [there is any usage limit], what is your mean? LoadFromFile need some time because your file is very large, even if you put it into a thread, it still need the same duration. Maybe you need put it into a thread, and run this thread at a right time such as before you want show these pictures. Such as, your game is nearly to the end of scense, but there are some seconds needed, then you start load file thread, and your user is still playing game, and when the game go end, your load file operation is complete. If you must free the resource of previous scense and then you have enough memory space to load the files the second scense need, then you need to show a transitions to user and then load file in a thread.
  20. I have some experience that using Indy TCP client to remote control some device through WiFi. My experience is that when the distance between mobile and device is out of range, you can test the connection by send some data and wait it timeout and in except section to close connection, like this: try IdTCPClient1.Send(....); except IdTCPClient1.Disconnect; end; and then try re-connect again, and again, and when mobile is into the range of device WiFi, you can connect again.
  21. pcplayer99

    FTP add virtual directory

    I have used Indy FTP server. You can start from Indy's demo code. How about ICS? I have never used ICS. On IIS server, you must close its own FTP server because it using port 21, and your own FTP server such as Indy TFP server will use it. Or, your own FTP server can setup to using other port, and you will tell your user to ftp another port such as: FTP://your-server-IP:2121
  22. Using Scanlines is for every pixels. You donn't need check every pixels here.
  23. Hi, I do not know MVVM, MVC etc. My experience is you should using interface in your code. And you should not using implement them with abstract classes. Abstract classes is not for interface. If you have another reason to using abstract classes you just use it but not for interface. For example, the framework of Delphi WebService is based on interface, and Delphi DataSnap framework is based on class. I like WebService framework but DataSnap framework.
  24. if the image file format is 32bit color bitmap, but the content is a black white picture, I think you can check it very quicklly by check pixels. You donn't need to check every pixels of the picture, you just need check severial pixels samples in the picture.
  25. I saw you said that is VCL APP, it is means run in Windows? If so, maybe you can use DirectShow framework. Another way is useing socket. To using share memory, you must handle the FPS yourself.
×