Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question How can i find metadata in a video/audio using OSMF player actionscript #84

Open
publicocean0 opened this issue Jun 14, 2017 · 0 comments

Comments

@publicocean0
Copy link

publicocean0 commented Jun 14, 2017

I m interested to find metadata inside video/audio: in particular if stream is a video or a audio , name, videoDimentions,texttrack languages.Could you give a sugestion how to do?

I tried also to add cues detection in your code.

if (!mediaElement) {
          var streamType:String = (isLive ? StreamType.LIVE : StreamType.RECORDED);
    
          urlResource = new StreamingURLResource(url, streamType, NaN, NaN, null, useAppInstance, null, proxyType);

          var startLevel:int = int(this.root.loaderInfo.parameters.startLevel);

          if (this.root.loaderInfo.parameters.switchRules != "") {
            var switchRules:Object = JSON.parse(this.root.loaderInfo.parameters.switchRules.replace(/&quote;/g, '"'));
            urlResource.addMetadataValue(MetadataNamespaces.RESOURCE_INITIAL_SWITCH_RULES, switchRules);
          }

          if (startLevel > -1) {
            urlResource.addMetadataValue(MetadataNamespaces.RESOURCE_INITIAL_INDEX, startLevel);
          }

          var pluginResource:MediaResourceBase = new PluginInfoResource(new SMILPluginInfo());

          // Load the plugin.
          mediaFactory.loadPlugin(pluginResource);

          //create new MediaPlayer - it controls your media provided in media property
          mediaPlayer = new MediaPlayer();

          mediaPlayer.bufferTime = this.root.loaderInfo.parameters.bufferTime;
          mediaPlayer.autoPlay = autoplay;
          mediaPlayer.autoDynamicStreamSwitch = this.root.loaderInfo.parameters.autoSwitch == 'true';
          mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onTimeUpdated);
          mediaPlayer.addEventListener(TimeEvent.DURATION_CHANGE, onDurationUpdated);
          mediaPlayer.addEventListener(TimeEvent.COMPLETE, onFinish);
          mediaPlayer.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError);
          mediaPlayer.addEventListener(DynamicStreamEvent.SWITCHING_CHANGE, onLevelSwitching);

          mediaElement = mediaFactory.createMediaElement(urlResource);

          mediaElement.addEventListener(MediaElementEvent.TRAIT_ADD, onTraitAdd);
          mediaElement.addEventListener(MediaElementEvent.METADATA_ADD, onMetadataAdd);

          mediaContainer.addMediaElement(mediaElement);

          mediaPlayer.media = mediaElement;

          //Set the player scaling
          playerScaling(this.root.loaderInfo.parameters.scaling);

          addChild(mediaContainer);
          resize();


          _changeStateAndNotify('PLAYING_BUFFERING')
          _triggerEvent('playbackready');
        }
      } catch (err:Error) {

        debugLog('Catch error: 1' + err.message+' '+err.getStackTrace());
        _changeStateAndNotify('ERROR')
      }
    }

     private function onMetadataAdd(event:MediaElementEvent):void
        {
            if (event.namespaceURL == CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE)
            {
                var timelineMetadata:TimelineMetadata = videoElement.getMetadata(CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE) as TimelineMetadata;
                timelineMetadata.addEventListener(TimelineMetadataEvent.MARKER_TIME_REACHED, onCuePoint);
            }
        }

    private function onCuePoint(event:TimelineMetadataEvent):void
        {
            var cuePoint:CuePoint = event.marker as CuePoint;
             _triggerEvent('oncue',JSON.stringify(cuePoint));

        }
@publicocean0 publicocean0 changed the title bower support question How can i find metadata in a video/audio using OSMF player actionscript Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant