Exemple #1
0
		public void SetSource (MediaStreamSource mediaStreamSource)
		{
			if (mediaStreamSource == null)
				throw new ArgumentNullException ("mediaStreamSource");

			Source = null;

			if (media_stream_source != null) {
				media_stream_source.CloseMediaInternal ();
				media_stream_source = null;
			}

			if (mediaStreamSource.Closed)
				throw new InvalidOperationException ();
			
			media_stream_source = mediaStreamSource;
			media_stream_source.SetMediaElement (this);
		}
 /// <inheritdoc /> 
 public void SetSource(MediaStreamSource mediaStreamSource)
 {
     MediaElement.SetSource(mediaStreamSource);
 }
 internal MediaLoadingEventArgs(MediaPlayerDeferrableOperation deferrableOperation, MediaStreamSource mediaStreamSource)
     : base(deferrableOperation)
 {
     MediaStreamSource = mediaStreamSource;
 }
        /// <inheritdoc />
        public void SetSource(MediaStreamSource mediaStreamSource)
        {
            Debug.WriteLine("MediaElementWrapper.SetSource(MediaStreamSource)");

            if (null != mediaStreamSource)
                MediaElement.SetSource(mediaStreamSource);
            else
                MediaElement.Source = null;
        }
 /// <inheritdoc /> 
 void IMediaElement.SetSource(MediaStreamSource mediaStreamSource)
 {
     throw new System.NotImplementedException();
 }
        public void loadMedia()
        {
            _isLoading = true;
            _firedCanPlay = false;

            WriteDebug("method:load " + media.CurrentState);
            WriteDebug(" - " + _mediaUrl.ToString());

            // Load custom MediaStreamSource
            switch (_codec)
            {
                case "audio/wav":
                    {
                        Stream stream = new PartialHTTPStream(_mediaUrl);
                        _streamSource = new WaveMediaStreamSource(stream);
                        media.SetSource(_streamSource);
                    }
                    break;

                case "audio/flac":
                    {
                        Stream stream = new PartialHTTPStream(_mediaUrl);
                        FlacBox.WaveOverFlacStream flacStream = new FlacBox.WaveOverFlacStream(stream, FlacBox.WaveOverFlacStreamMode.Decode);
                        _streamSource = new WaveMediaStreamSource(flacStream);
                        media.SetSource(_streamSource);
                    }
                    break;

                default:
                    _streamSource = null;
                    media.Source = new Uri(_mediaUrl, UriKind.Absolute);
                    break;
            }
        }
Exemple #7
0
        /// <summary>
        /// Goes to a playlist item.
        /// </summary>
        /// <param name="playlistItemIndex">The index of the playlist item to go to.</param>
        public void GoToPlaylistItem(int playlistItemIndex)
        {
            Debug.WriteLine("GoToPlaylistItem: " + playlistItemIndex.ToString(CultureInfo.CurrentCulture));
            if (playlistItemIndex >= 0 && playlistItemIndex < Playlist.Count)
            {
                m_currentChapterIndex = 0;

                bool canSkipReset = m_currentPlaylistIndex == playlistItemIndex;
                if (canSkipReset)
                {
                    switch (m_mediaElement.CurrentState)
                    {
                        case MediaElementState.Closed:
                        case MediaElementState.Stopped:
                            canSkipReset = false;
                            break;
                        default:
                            break;
                    }
                }

                if (!canSkipReset)
                {
                    m_currentPlaylistIndex = playlistItemIndex;

                    if (m_listBoxChapters != null)
                    {
                        m_listBoxChapters.ItemsSource = Playlist[m_currentPlaylistIndex].Chapters;
                    }

                    // Update window title with playlist item title (or filename)
                    if (HtmlPage.Document != null)
                    {
                        string newTitle = string.Empty;
                        if (!string.IsNullOrEmpty(Playlist[m_currentPlaylistIndex].Title))
                        {
                            newTitle = Playlist[m_currentPlaylistIndex].Title;
                        }
                        else
                        {
                            if (Playlist[m_currentPlaylistIndex].IsAdaptiveStreaming)
                            {
                                newTitle = System.IO.Path.GetDirectoryName(Playlist[m_currentPlaylistIndex].MediaUrl.OriginalString);
                                newTitle = System.IO.Path.GetFileName(newTitle);
                            }
                            else
                            {
                                newTitle = System.IO.Path.GetFileName(Playlist[m_currentPlaylistIndex].MediaUrl.OriginalString);
                            }
                        }

                        HtmlPage.Document.SetProperty("title", newTitle);
                    }

                    // Attach media source to the MediaElement
                    m_currentItemIsAdaptive = Playlist[m_currentPlaylistIndex].IsAdaptiveStreaming;
                    if (m_currentItemIsAdaptive)
                    {
                        // The old source will get cleaned up when the media element
                        // closes it, so we do not have to explicitly close it here.
                        // Use our factory method to create it
                        if (MediaStreamSourceFactory != null)
                        {
                            m_mediaStreamSource = MediaStreamSourceFactory.Create(m_mediaElement, Playlist[m_currentPlaylistIndex].MediaUrl);
                            m_mediaElement.SetSource(m_mediaStreamSource);
                        }
                    }
                    else
                    {
                        m_mediaElement.Source = Playlist[m_currentPlaylistIndex].MediaUrl;

                        // Set the media stream source to null because we are not using it
                        m_mediaStreamSource = null;
                    }

                    // Update and show the poster frame for the current item
                    DisplayPoster(m_currentPlaylistIndex);
                }

                // Ensure play starts at the beginning of the new item
                SeekToTime(0);

                // Start playing or Pausing the item depending on user settings and current play state.
                if (m_inPlayState || m_autoPlayCache)
                {
                    InternalPlay();
                }
                else if (m_autoLoadCache)
                {
                    InternalPause();
                }
                else
                {
                    // Display the start button when user options niether start nor load the video on page load.
                    if (m_buttonStart != null)
                    {
                        m_buttonStart.Visibility = Visibility.Collapsed;
                    }
                }
            }
            else if (playlistItemIndex >= Playlist.Count)
            {
                // Reached end -- flag that playback is paused.
                m_inPlayState = false;
            }
        }
 void Initialize() {
   var spss = new StereoPcmStreamSource();
   _oscillator = new Oscillator() { Frequency = 0 };
   spss.Input = _oscillator;
   _Source = spss;
 }
Exemple #9
0
 public AudioInstanceMediaElement(MediaStreamSource source)
 {
     this.mSource = source;
     CreateMediaElement();
 }