is it possible to open up a m3u webradio stream in a MediaElement class in Windows 10?
Sample stream would be
http://www.antenne.de/webradio/channels/top-40.m3u
Opening normal mp3 in the internet work perfect but i do not get any m3u file opened.
Kind regards
Michael
Starting from Windows 10 version 1607, it is recommended to use the MediaPlayer class instead of MediaElement for media playback & The lightweight XAML control MediaPlayerElement.
Then you can use the MediaPlaybackList to create playlist for the MediaPlayer.
StorageFolder vfolder = Windows.Storage.KnownFolders.VideosLibrary;
StorageFileQueryResult query = vfolder.CreateFileQueryWithOptions(Constants.QueryOptions);
var files = await query.GetFilesAsync();
MediaPlaybackList playbackList = new MediaPlaybackList();
foreach (StorageFile file in files)
{
MediaSource source = MediaSource.CreateFromStorageFile(file);
playbackList.Items.Add(new MediaPlaybackItem(source));
}
_mediaPlayer = new MediaPlayer();
_mediaPlayer.AutoPlay = true;
_mediaPlayer.Source = playbackList;
MPElement.SetMediaPlayer(_mediaPlayer);
_mediaPlayer.Play();
More information Microsoft Docs
In m3u file (playlist file), there are often links point out to the source of audio. You need to get the file, open, parse it to get urls, and supply one of them to MediaElement. Its the same when you try to streaming video.
A M3U file isn't supported as it's not a media file. The playlist file format is simple and documented well enough that I'd recommend just parsing the M3U file and playing the individual files.
Unfortunately, Windows 10 UWP apps do not have access to the Playlist class which would be helpful in your scenario. It's only available for Desktop applications and in a Windows 8 app.
Related
I have gone through the answer provided here for the difference. But I need to just play notification sound for like 2 seconds as an alert. No video or any other heavy loading.
This is the notification sound I am about to play.
ms-winsoundevent:Notification.SMS
The below is for MediaPlayerElement:
MediaPlayerElement mediaPlayerElement = new MediaPlayerElement();
mediaPlayerElement.SetMediaPlayer(new Windows.Media.Playback.MediaPlayer { AudioCategory = Windows.Media.Playback.MediaPlayerAudioCategory.Alerts});
mediaPlayerElement.MediaPlayer.AudioCategory = Windows.Media.Playback.MediaPlayerAudioCategory.Alerts;
mediaPlayerElement.Source = Windows.Media.Core.MediaSource.CreateFromUri(new Uri("ms-winsoundevent:Notification.Default"));
mediaPlayerElement.AutoPlay = false;
mediaPlayerElement.MediaPlayer.Play();
The below is for MediaElement:
MediaElement mediaElement = new MediaElement();
mediaElement.AudioCategory = AudioCategory.Alerts;
mediaElement.Source = new Uri("ms-winsoundevent:Notification.Default");
mediaElement.AutoPlay = false;
mediaElement.Play();
Can I use MediaElement since its a small audio or should I only use MediaPlayerElement as it is the one prescribed by Microsoft? which one is better to use in this case?
P.S.: I need to set audio category as Alerts in order to dim any background music.
Can I use MediaElement since its a small audio or should I only use MediaPlayerElement as it is the one prescribed by Microsoft? which one is better to use in this case?
Derive from official document,
In Windows 10, build 1607 and on we recommend that you use MediaPlayerElement in place of MediaElement. MediaPlayerElement has the same functionality as MediaElement, while also enabling more advanced media playback scenarios. Additionally, all future improvements in media playback will happen in MediaPlayerElement.
And it means that the new feature will be developed base on the MediaPlayerElement, we recommend using MediaPlayerElement that could make your app has longer life.
Google has somewhat recently rolled out the ability to insert audio files from your Drive into Slides with various playback options.
I cannot find any documentation on how to insert a file through Google Scripts but can do so going through the available menu options. I tried using the insertVideo method but got an error
"Exception: The parameters (DriveApp.File) don't match the method signature for SlidesApp.Slide.insertVideo."
Here is a general function I'm trying to get to work (NOOB disclaimer goes here):
function uploadAudioToCurrentSlide(){
var presentation = SlidesApp.getActivePresentation();
var currentSlide = presentation.getSlides()[0];
var audioFile = DriveApp.getFileById('idofaudiofileindrive');
currentSlide.insertVideo(audioFile);
}
Any help is most appreciated!
You want to insert a audio file in Google Drive to Google Slides using Google Apps Script.
Issue and workaround:
I think that the reason of your issue is that the file object is directly used to the method of insertVideo. The argument of insertVideo is the URL and the video object which is not the file object. By this, such error occurs.
In the current stage, when the method of insertVideo is used, the video content is required to be the publicly shared YouTube URL.
And also, it seems that the audio file cannot be directly inserted.
Unfortunately, it seems that these are the current specification. So as a workaround, how about the following flow?
At first, convert the audio file to a video file like MP4. As a test, this can be done at other site. But I'm not sure about the file type of your audio file.
Insert the converted MP4 file on Google Drive using Slides API.
When the Slides API is used, you can insert the video file in Google Drive to the Google Slides. In this sample script, "CreateVideoRequest" of the batchUpdate method of Slides API is used.
Sample script:
Before you run the script, please enable Slides API at Advanced Google services.
function myFunction() {
var fileId = "###"; // Please set the file ID of the converted video file on Google Drive.
var presentation = SlidesApp.getActivePresentation();
var currentSlide = presentation.getSlides()[0];
var resource = {requests: [{createVideo: {source: "DRIVE", id: fileId, elementProperties: {pageObjectId: currentSlide.getObjectId()}}}]};
Slides.Presentations.batchUpdate(resource, presentation.getId());
}
Note:
When you can upload the audio file to YouTube and publicly share it, you can use your script using the URL of the YouTube.
References:
insertVideo(videoUrl)- Advanced Google services
Method: presentations.batchUpdate
CreateVideoRequest
I receive over network PCM audio data stream and this part works fine so I am ending up with
DataReader incomming = args.GetDataReader();
byte[] RcvBuffer = new byte[incomming.UnconsumedBufferLength];
incomming.ReadBytes(RcvBuffer);
I have all audio data in buffer.
How I can play this through telephone Speaker ? Can you point me in some direction ?
Thanks
There're many ways to do that.
You can prepend the WAVE header to your data, and use MediaElement for playback, see the documentation for SetSource method.
If however by “telephone speaker” you mean the earphone, then it is only possible if you are creating a VoIP app.
It took a while but I sorted it, maybe someone else will need help in the future.
First Problem - since I just started app development for Windows Phone I have chosen Blank App (Windows Phone) instead Blank App (Windows Phone Silverlight) and I did not have access to many features that are available in Silverlight projects, so my suggestions for beginners: understand what each project is for.
Like Soonts said there are many ways to do this, this is one that I used.
I simplified this code and retyped this so there can be some typos.
using Microsoft.Xna.Framework.Audio;
using System.IO;
1) Create Stream to load your incoming data:
MemoryStream stream = new MemoryStream();
2) Load data from buffer to stream:
stream.Write(RcvBuffer, 0, RcvBuffer.Length);
3) I am using SoundEfect to play this through Loud-Speaker. Sample rate that I use is 8 kHz
SoundEffect sound;
sound = new SoundEffect(stream.toArray(), 8000, AudioChannels.Mono)
sound.Play();
Is there a way to read the info (fps, bitrate, duration, codecs required, etc.) of a media file (avi, mp4, mkv, etc.) on windows using visual studio c++?
I managed to play various files (which I actually don't even want) using directshow (http://msdn.microsoft.com/en-us/library/windows/desktop/dd389098%28v=vs.85%29.aspx) but I don't know how to only get the information from the file.
Edit: I got it working like this...
int height, width, framerate, bitrate;
LARGE_INTEGER duration;
// initialize the COM library
CoInitialize(NULL);
//
IPropertyStore* store = NULL;
SHGetPropertyStoreFromParsingName(L"E:\\test.avi", NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)&store);
PROPVARIANT variant;
store->GetValue(PKEY_Media_Duration, &variant);
duration = variant.hVal;
store->GetValue(PKEY_Video_FrameHeight, &variant);
height = variant.lVal;
store->GetValue(PKEY_Video_FrameWidth, &variant);
width = variant.lVal;
store->GetValue(PKEY_Video_FrameRate, &variant);
framerate = variant.lVal;
store->GetValue(PKEY_Video_TotalBitrate, &variant);
bitrate = variant.lVal;
//
store->Release();
//
CoUninitialize();
You can obtain this information via DirectShow, however if you don't need the playback/streaming pipeline and you are on Windows 7, then you possibly have a better alternate option to get the data from shell properties - those supplying data to display in additional columns of Windows explorer.
SHGetPropertyStoreFromParsingName gets you property store
MSDN entry point for Shell Metadata Providers
Code snippet: How to use the IPropertyStore to obtain Media_Duration?
Have you considered using the MediaInfo SDK? You can get extensive information about all of the audio and video streams available in the container, including codec specifics, as well as everything you were asking about.
Their getting started guide and reference documentation are here:
http://mediaarea.net/en/MediaInfo/Support/SDK/Quick_Start
http://mediaarea.net/en/MediaInfo/Support/SDK/More_Info
Code is available at their SourceForge page here.
I would like to create a simple add-on that would play a different MP3 recording every time the user double clicks a word in a webpage he is visiting and selects a special option from the context menu.
The MP3 files are located on a remote server. Normally I would use JavaScript+Flash to play the MP3 file. In a Firefox add-on, however, I'm unable to load external scripts for some reason (playing the sound works fine if it's the webpage itself that loads the scripts, but of course I need it to work with every website and not just the ones that include the script).
So what's the easiest way to play a remote MP3 file in a Firefox add-on using JavaScript?
This may not entirely solve your question, as I don't BELIEVE it plays MP3s, but I'm not certain.
Firefox has nsISound, which I KNOW can play remote WAV files, as I've tested and proved it.
You may want to test it for yourself and see if it leads you a little closer!
var ios = Components.classes['#mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);
var sound = ios.newURI("http://www.yoursite.com/snds/haha.wav", null, null);
var player = Components.classes["#mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
player.play(sound);
Good luck, I hope this at least gets you close!
I know this is an old question, but if someone needs a way to do it:
let player = document.createElement("audio");
player.src = browser.runtime.getURL(SOUND_URL);
player.play();
There is one caveat: the user must have allowed autoplay on the website.
Here is a working code....
var sound = Components.classes["#mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
var soundUri = Components.classes['#mozilla.org/network/standard-url;1'].createInstance(Components.interfaces.nsIURI);
soundUri.spec = "chrome://secchat/content/RING.WAV";
sound.play(soundUri);
var window = require('sdk/window/utils').getMostRecentBrowserWindow();
var audio = ('http://example.com/audio.mp3');
audio.play();