1
0

FLVExternalInterface.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "FLVExternalInterface.h"
  2. #include "../xml/obj_xml.h"
  3. #include "api.h"
  4. #include "SWFParameters.h"
  5. #include "../Winamp/wa_ipc.h"
  6. #include "main.h"
  7. #include <api/service/waServiceFactory.h>
  8. #include <strsafe.h>
  9. BSTR FLVExternalInterface::ExternalInterface_call(BSTR xml)
  10. {
  11. obj_xml *parser=0;
  12. waServiceFactory *parserFactory = plugin.service->service_getServiceByGuid(obj_xmlGUID);
  13. if (parserFactory)
  14. parser = (obj_xml *)parserFactory->getInterface();
  15. if (parser)
  16. {
  17. { // artificial scope for SWFParameters
  18. SWFParameters parameters(parser);
  19. parser->xmlreader_open();
  20. parser->xmlreader_setEncoding(L"UTF-16");
  21. parser->xmlreader_feed(xml, wcslen(xml)*sizeof(*xml));
  22. parser->xmlreader_feed(0, 0);
  23. parser->xmlreader_close();
  24. if (parameters.functionName)
  25. {
  26. if (!wcscmp(parameters.functionName, L"Benski"))
  27. {
  28. }
  29. else if (!wcscmp(parameters.functionName, L"Ready"))
  30. {
  31. unsigned int width, height;
  32. if (parameters.GetUnsigned(0, &width) && parameters.GetUnsigned(1, &height))
  33. videoOutput->open(width, height, 0, 1.0f /*(double)x/(double)y*/, VIDEO_MAKETYPE('N','O','N','E'));
  34. // TODO:
  35. // Play (if not paused during buffering)
  36. }
  37. else if (!wcscmp(parameters.functionName, L"Complete"))
  38. {
  39. PostMessage(plugin.hMainWindow, WM_WA_MPEG_EOF, 0, 0);
  40. }
  41. else if (!wcscmp(parameters.functionName, L"Metadata"))
  42. {
  43. // MessageBox(NULL, xml, L"Flash ExternalInterface.call()", MB_OK);
  44. double duration;
  45. if (parameters.GetDouble(0, &duration))
  46. playLength = (int)(duration * 1000.0);
  47. }
  48. else if (!wcscmp(parameters.functionName, L"Buffering"))
  49. {
  50. Nullsoft::Utility::AutoLock autolock(statusGuard);
  51. StringCchCopy(status, 256, L"buffering");
  52. PostMessage(plugin.hMainWindow, WM_USER, 0, IPC_UPDTITLE);
  53. }
  54. else if (!wcscmp(parameters.functionName, L"Playing"))
  55. {
  56. Nullsoft::Utility::AutoLock autolock(statusGuard);
  57. status[0]=0;
  58. PostMessage(plugin.hMainWindow, WM_USER, 0, IPC_UPDTITLE);
  59. }
  60. else if (!wcscmp(parameters.functionName, L"Playhead"))
  61. {
  62. double playhead;
  63. if (parameters.GetDouble(0, &playhead))
  64. playPosition = (int)(playhead * 1000.0);
  65. }
  66. }
  67. }
  68. parserFactory->releaseInterface(parser);
  69. }
  70. return 0;
  71. }