/src/org/osmf/player/elements/ErrorElement.as

https://github.com/aravindakumar/StrobeMediaPlayback
ActionScript | 85 lines | 37 code | 13 blank | 35 comment | 0 complexity | 721c3213ffc25a133fcc7ee09c2429f3 MD5 | raw file
  1. /***********************************************************
  2. * Copyright 2010 Adobe Systems Incorporated. All Rights Reserved.
  3. *
  4. * *********************************************************
  5. * The contents of this file are subject to the Berkeley Software Distribution (BSD) Licence
  6. * (the "License"); you may not use this file except in
  7. * compliance with the License.
  8. *
  9. * Software distributed under the License is distributed on an "AS IS"
  10. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  11. * License for the specific language governing rights and limitations
  12. * under the License.
  13. *
  14. *
  15. * The Initial Developer of the Original Code is Adobe Systems Incorporated.
  16. * Portions created by Adobe Systems Incorporated are Copyright (C) 2010 Adobe Systems
  17. * Incorporated. All Rights Reserved.
  18. *
  19. **********************************************************/
  20. package org.osmf.player.elements
  21. {
  22. import flash.display.DisplayObject;
  23. import flash.display.Graphics;
  24. import flash.display.Sprite;
  25. import org.osmf.player.chrome.assets.AssetsManager;
  26. import org.osmf.player.chrome.widgets.LabelWidget;
  27. import org.osmf.layout.LayoutMetadata;
  28. import org.osmf.layout.VerticalAlign;
  29. import org.osmf.media.MediaElement;
  30. import org.osmf.player.chrome.ChromeProvider;
  31. import org.osmf.traits.DisplayObjectTrait;
  32. import org.osmf.traits.PlayTrait;
  33. import org.osmf.traits.SeekTrait;
  34. import org.osmf.traits.TimeTrait;
  35. /**
  36. * Defines a media element that displays an error. The element is used
  37. * with play lists: if an element runs into trouble, the original element
  38. * is removed, and this error element is inserted in its place.
  39. *
  40. * An error element has a time trait: it plays for 5 seconds.
  41. */
  42. public class ErrorElement extends MediaElement
  43. {
  44. // Public Interface
  45. //
  46. public function ErrorElement(errorMessage:String)
  47. {
  48. this.errorMessage = errorMessage;
  49. super();
  50. }
  51. // Overrides
  52. //
  53. override protected function setupTraits():void
  54. {
  55. super.setupTraits();
  56. // Setup a AlertDialog using the ChromeLibrary based ChromeProvider:
  57. var chromeProvider:ChromeProvider = ChromeProvider.getInstance();
  58. chromeProvider.createErrorWidget();
  59. var errorWidget:ErrorWidget = chromeProvider.getWidget("error") as ErrorWidget;
  60. errorWidget.errorMessage = errorMessage;
  61. errorWidget.measure();
  62. // Make the widget's layout metadata, the element's metadata:
  63. addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, errorWidget.layoutMetadata);
  64. // Add a view trait, using the widget's display object:
  65. var viewable:DisplayObjectTrait = new DisplayObjectTrait(errorWidget, errorWidget.measuredWidth, errorWidget.measuredHeight);
  66. addTrait(viewable.traitType, viewable);
  67. }
  68. // Internals
  69. //
  70. private var errorMessage:String;
  71. }
  72. }