Implementation of RTSP by j2-based systems (only available on supported mobile phones)

Source: Internet
Author: User
  1. ImportJavax. microedition. lcdui .*;
  2. ImportJavax. microedition. MIDlet .*;
  3. ImportJavax. microedition. Media .*;
  4. ImportJavax. microedition. Media. Control .*;
  5. /**
  6. * A simple example of the mmapi (JSR 135) Support for streaming video
  7. * With the Sony Ericsson v800.
  8. *
  9. * This code is part of the tips & tricks section
  10. * Www.sonyericsson.com/developer
  11. *
  12. * Copyright All Rights Reserved Sony Ericsson Mobile Communications AB 2005.
  13. * The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
  14. * The use of the software is subject to the terms of the end-user license
  15. * Agreement which accompanies or is wrongly ded with the software. The software is
  16. * Provided "as is" and Sony Ericsson specifically disclaim any warranty or
  17. * Condition whatsoever regarding merchantability or fitness for a specific
  18. * Purpose, title or non-infringement. No warranty of any kind is made in
  19. * Relation to the condition, suitability, availability, accuracy, reliability,
  20. * Merchantability and/or non-infringement of the software provided herein.
  21. *
  22. */
  23. Public ClassStreamingvideoExtendsMIDletImplementsCommandlistener, playerlistener, runnable {
  24. PrivateDisplay mydisplay;
  25. PrivateForm myform;
  26. PrivateThread streamingthread;
  27. PrivatePlayer myplayer;
  28. PrivateVideocontrol VC;
  29. Private BooleanRunning =False;
  30. PublicStreamingvideo (){
  31. Mydisplay = display. getdisplay (This);
  32. Myform =NewForm ("streaming test ");
  33. Myform. addcommand (NewCommand ("exit", command. Exit, 0 ));
  34. Myform. addcommand (NewCommand ("START", command. OK, 0 ));
  35. Myform. setcommandlistener (This);
  36. }
  37. Protected VoidStartapp ()ThrowsMidletstatechangeexception {
  38. Mydisplay. setcurrent (myform );
  39. Streamingthread =NewThread (This);
  40. }
  41. Protected VoidPauseapp (){}
  42. Protected VoidDestroyapp (BooleanUnconditional ){
  43. Try{
  44. Myplayer. Stop ();
  45. Myplayer. Close ();
  46. }
  47. Catch(Exception e ){
  48. Log ("exception:" + E. tostring ());
  49. }
  50. }
  51. /**
  52. * Inits and starts the player for video streaming
  53. */
  54. Private VoidStartstreaming (){
  55. Try{
  56. Myplayer = manager. createplayer ("rtsp: // yourserver/mobile/realmp3.3gp ");
  57. Myplayer. addplayerlistener (This);
  58. Myplayer. Realize ();
  59. // Grab the video control and set it to the current display.
  60. VC = (videocontrol) myplayer. getcontrol ("videocontrol ");
  61. If(VC! =Null){
  62. Myform. append (item) VC. initdisplaymode (VC. use_gui_primitive,Null));
  63. // Sets the display size of the video.
  64. VC. setdisplaysize (120,160 );
  65. }
  66. Myplayer. Start ();
  67. }Catch(Exception e ){
  68. Log ("exception:" + E. tostring ());
  69. Myform. append ("exception:" + E. tostring ());
  70. }
  71. }
  72. Public VoidCommandaction (command C, displayable s ){
  73. If(C. getcommandtype () = command. Exit ){
  74. Running =False;
  75. Yydestroyed ();
  76. }Else{
  77. Streamingthread. Start ();
  78. }
  79. }
  80. /**
  81. * Playerlistener interface method, logs all player event.
  82. */
  83. Public VoidPlayerupdate (player, string event, object eventdata ){
  84. Log ("** playerupdate:" + event + "**");
  85. }
  86. Public VoidLog (string MSG ){
  87. System. Out. println (MSG );
  88. }
  89. Public VoidRun (){
  90. Running =True;
  91. Startstreaming ();
  92. While(Running ){
  93. Thread. Yield ();
  94. }
  95. }
  96. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.