Switch Mediaelement control - windows-phone-7

I have one page which contains 2 Media Element Control, first I use one Media Element control to play video(play success) and then I use second Media Element control to play mp3 file but it's not play. I tried to set source = null, call function Stop() to stop first Media Element but Second Media Element is not play. Any body here can help me?. Thanks.

Multiple MediaElements do not seem to be supported, as documented here :-
http://msdn.microsoft.com/en-us/library/ff426928(VS.96).aspx
Hope this helps.
Paul Diston

Multiple MediaElements are not supported but you can use the XNA SoundEffect and the MediaElement.
Playing video and audio at the same time

Related

Manually chosen rendition is not taking effect on the brightcove player

I'm changing the video rendition using the setRenditionSelectionCallback as explained here http://support.brightcove.com/en/video-cloud/docs/selecting-multi-bitrate-streaming-renditions. But seems like the rendition I choose is never being displayed, even when in the brightcove debugger I see messages like:
Attempting to change rendition that the player expects to play from (110000b/s, 400x224) to (800000b/s, 640x360)
New rendition chosen from external rendition algorithm.
Is there anything else that should be done for update the rendition that is being displayed? Or is it a know issue? I'm only updating the rendition index in the setRenditionSelectionCallback callback.
Thanks in advance for any help here! :)
I was trying to change dynamically the rendition in a progressive download account. In this kind of accounts the rendition selection is only possible at the very start.
It is possible to force a rendition change with a progressive account by using a different method, but that will restart playback (and download) from the beginning again. There's an existing plugin doing that: https://github.com/BrightcoveOS/Rendition-Selector-Plugin.

Embedded youtube video with "autoplay=1". Does it count towards views?

I can cause an embed youtube video to begin playing automatically using "autoplay=1"
When a user views the embedded video does it count towards my views count?
I have attempted to test but had inconclusive results. Viewed embedded videos to not appear to consistently convert to views even when play is manually clicked.
My tests have been from a single machine and IP which may be the problem? Browser session does not seem to be relevant.
There's been some discussions regarding this topic. Here's a thread with some contradictory answers:
Does the views in the embed player count?
And here's an article about an official response from Youtube claiming that autoplay views does not count:
Youtube Says Autoplay Don't Count
Here's another one that claims that embedded videos with autoplay doesn't count:
How does YouTube video view count work?
(found through this SO answer)
Note 1: Note that there seems to exist "cheats" and bugs, but Youtube claims to be working to prevent it. This means that, if you're using their API in a regular way, your autoplay views probably doesn't count.
Note 2: The above note is simply Youtube's official statement. Who knows what's really going on. Some people (including you, OP) are getting mixed results.
The bottom line is, don't count on it (pun intended).
Short answer: NO
I found this official documentation on the subject (however it's regarding the Custom gadget development guidelines)
Rule of Thumb:
Any time a user initiates a playback using the native player controls, that playback should count. Using an API method to PLAY a video does not count. BUT, you can use cueVideoById and then have the user click a native built in play button and it will count.
Views will NOT be counted if:
The user initiates playback via an API method like playVideo or loadVideoById
The video autoplays via the autoplay parameter
You can try adding the attribute "enablejsapi=1" . This will increase the view count in youtube.com site
No. It was a long search, but the answer seems to be hidden here. Follow the link to check it out.
Taken from here.
https://support.google.com/youtube/answer/171780?hl=en&ref_topic=3014330

MediaElement repeat play

I want to play a video file in mediaelement repeatedly, but when I try to play video again in the MediaEnded event MediaElement clears screen and screen is still clear for some little but appreciable time range. How to decrease this time range or dispose of it?
Thanks.
Could you provide the code for the MediaEnded-event? A bit looking for me resulted in this:
How to: Repeat Media Playback
Social.MSDN: Repeat MediaElement
Perhaps one of these approaches works better?
I also found out that this is a known issue in Silverlight (don't know if this also relates to the WP7 version): Looping with Silverlight media element - a small delay at end of clip before it plays
Hope this helps!

WP7 MediaElement Unable to Reposition the stream

I am using MediaElement for video playback in my app. I have added controls for play, pause, rewind and forward. In the forward button's event handler, I am trying to forward the video clip for 5 seconds. the code I have used to do that is given below.
if(myMediaElement.CanSeek)
{
myMediaElement.Position = TimeSpan.FromSeconds(2);
myMediaElement.Play();
}
But the video clip does not forward, instead it stops the video playback. Can anyone please tell me what is going wrong.
You need to start playing the stream before you can set the position.
Move the call to CanSeek and the setting of the position until after the MediaOpened event has been raised.
See the remarks in MSDN http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.position(v=VS.95).aspx for confirmation.
Using valueconverter sample here, with Slider adjustments, to get the positions
http://diggthedrazen.com/2011/07/08/using-an-ivalueconverter-to-create-a-player-with-a-seek-bar-on-windows-phone/

WP7 play many compressed (mp3, wma etc) audio files simultaneously/dynamically

For size reasons I need to bundle a WP7 app with compressed audio (mp3, wma etc). How do I play these freely/simultaneously?
The XNA framework only supports WAV files, so unless there is a pure C# managed code library somewhere to decompress mp3/wma/ogg (?) on the fly, the next option would be...
MediaElement. But I don't get good results with MediaElement. It seems that you need to add a MediaElement specifically as a tag in the xaml, and you can't use several instances (several tags). As soon as I play a certain MediaElement I can't play another MediaElement on the same page. I don't find anything about a restriction in the reference (the reference is very empty).
I also tried dynamically creating MediaElement objects, but that doesn't seem valid at all, or I just cannot get it to play the files at all.
Use the built-in XNA content pipeline sound effect compression!
The default setting for a SoundEffect content type is "Best" compression quality (which appears to, in fact, be no compression at all). Set the compression quality to "Low" and you will get a much, much smaller file. Or "Medium" for a nice balance between size and quality.
To change this setting, select your .wav file in the solution explorer, press F4 to bring up the properties window, expand the "Content Processor" node, and change the compression quality setting that appears.
Here are instructions with screenshots:
Create a new WP7 XNA game project (or otherwise get an XNA Content Project)
Add a wav file to the content project:
Press F4 with the wav file selected in the Solution Explorer to bring up the properties window.
Expand the "Content Processor" node and change the compression quality to the desired setting.
A setting of "Best" gives no compression (raw waveform), settings of "Medium" and "Low" give a much smaller file.
In my experience currently there's no good solution for this on WP7. Either you use wavs with XNA and grow the size of the xap or use mp3s with the very limited MediaElement functionalty, compromising on what you can implement with it.
You might be able to port some C# audio libraries to WP7, I haven't heard of any so far so it might be long shot.
In one of my apps I finally decided to go with the wav + XNA combination after playing around with different options for a good while.
using Microsoft.Xna.Framework.Media;
void PlaySound(string pathToMp3) {
Song song = Song.FromUri("name", new Uri(pathToMp3, UriKind.Relative));
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
MediaPlayer.Play(song);
}
You could use MediaElement and set the source to the mp3, but this cannot be changed from code as in.
MediaElement me = sender as MediaElement;
me.Source = new Uri(
as you cannot load resources into the source.
you could use multiple MediaElements in your xaml and stop them and start the ones you require. As long as you predetermined which files you wanted to load at compile time.
You could also combine those files into one and play them at a particular location, like so.
me.Position = new TimeSpan(0, 0, 0, 0, 1);
me.Play();

Resources